Deploying rails 3.1 application to amazon EC2 Instance with Capistrano connection failed error

Followed the step in the

Able to connect to the ec2 as a User with SSH. ( key is in
~/.ssh folder )

  1. Create a user geoman in ec2.
  2. created public and private key for the user.
  3. Copied the public key to ec2 and able to SSH as user to ec2 from
    mac shell. ssh -i ~/.ssh/geoman -l geoman

Able to create a test rails project, place in local git and setup

Here is the deploy.rb

set :application, “awstestapp”
set :repository, “.”

set :scm, :git

Or: accurev, bzr, cvs, darcs, git, mercurial,

perforce, subversion or none

set :location, “
role :web, location # Your HTTP server,
role :app, location # This may be the same as
your Web server
role :db, location, :primary => true # This is where Rails migrations
will run
#role :db, “your slave db-server here”

The directory on the EC2 node that will be deployed to

set :deploy_to, “/var/www/vhosts/#{application}”

The way in which files will be transferred from repository to remote


If you were using a hosted github repository this would be slightly

set :deploy_via, :copy

Set up SSH so it can connect to the EC2 node - assumes your SSH key

is in ~/.ssh/id_rsa
set :user, [File.join(ENV[“HOME”], “.ssh”, “geoman”)]

if you’re still using the script/reaper helper you will need

these GitHub - rails/irs_process_scripts: WARNING: this repo is not maintained anymore, if you want to maintain it, please send an mail to rails-core. The extracted inspector, reaper, and spawner scripts from script/process/*

If you are using Passenger mod_rails uncomment this:

namespace :deploy do

task :start do ; end

task :stop do ; end

task :restart, :roles => :app, :except => { :no_release => true }


run "#{try_sudo} touch




Run the command - cap deploy:setup FAILED

NOTE: [( key is in ~/.ssh folder )]

  • executing `deploy:setup’
    • executing “sudo -p 'sudo password: ’ mkdir -p /var/www/vhosts/
      awstestapp /var/www/vhosts/awstestapp/releases /var/www/vhosts/
      awstestapp/shared /var/www/vhosts/awstestapp/shared/system /var/www/
      vhosts/awstestapp/shared/log /var/www/vhosts/awstestapp/shared/pids”
      servers: [“”]
      connection failed for: (Net::SSH::AuthenticationFailed: /Users/

what do I miss here? any help is appreciated.

On Dec 12, 4:28am, Geo M. [email protected] wrote:

Set up SSH so it can connect to the EC2 node - assumes your SSH key

is in ~/.ssh/id_rsa
set :user, [File.join(ENV[“HOME”], “.ssh”, “geoman”)]

I think you copied from that blog post too hastily - :user should be
set to the user name, not the path to the ssh key, which is set