Take the 2-minute tour ×

Why am I getting authenicationFailed when I try to run deploy setup? I am using the ssh as my password. Do I need to change anything in the database.yml or deploy.rb. They are listed below.

$ cap deploy:setup
  * executing `deploy:setup'
  * executing "sudo -p 'sudo password: ' mkdir -p /var/www/apps/sample_app /var/www/apps/sample_app
 /releases /var/www/apps/sample_app/shared /var/www/apps/sample_app/shared/system /var/www     
/apps/sample_app/shared/log /var/www/apps/sample_app/shared/pids"
    servers: ["ec2-20-21-42-51.compute-1.amazonaws.com"]
connection failed for: ec2-20-21-42-51.compute-1.amazonaws.com 
(Net::SSH::AuthenticationFailed: ubuntu)


# The name of your app
set :application, "sample_app"

# The directory on the EC2 node that will be deployed to

set :keep_releases, 3

# deploy with git
set :scm, :git
set :repository,  "git@github.com:username/sample_app.git"
set :git_shallow_clone, 1
set :branch, "master"
set :use_sudo, true

set :user, "ubuntu"
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

set :location, "ec2-20-21-42-51.compute-1.amazonaws.com"

# setup some Capistrano roles
role :app, location
role :web, location
role :db,  location, :primary => true

after 'deploy:update_code', 'deploy:symlink_db'

namespace :deploy do

desc "Restart Application"
task :restart, :roles => :app do
run "touch #{deploy_to}/#{shared_dir}/tmp/restart.txt"

desc "Symlinks the database.yml"
task :symlink_db, :roles => :app do



  adapter: mysql2
  database: db/development.mysql2
  pool: 5
  timeout: 5000
  database: sample_app
  username: root
  socket: /tmp/mysql.sock

  adapter: mysql2
  database: db/test.mysql2
  pool: 5
  timeout: 5000
  database: sample_app
  username: root
  socket: /tmp/mysql.sock

  adapter: mysql2
  database: db/production.mysql2
  pool: 5
  timeout: 5000
  database: sample_app
  username: ubuntu
  socket: /var/run/mysqld/mysqld.sock
share|improve this question
add comment

3 Answers

up vote 10 down vote accepted

Specify the location of your pem file

ssh_options[:keys] = ["/where/ever/it/is/key.pem"]
share|improve this answer
how should we handle this when several developers deploy? –  juanpastas Apr 29 '13 at 18:11
add comment

Do you have "sudo" rights? Is user "ubuntu" in sudo group?

share|improve this answer
I had to add ssh_options[:keys] = ["/Users/Victoria/Documents/ServerKeys/key.pem"] to my deploy.rb file –  SilverNightaFall May 17 '12 at 0:04
If you can use "sudo" rights, you must allow it for your user (ubuntu). Problem is not in capistrano or RoR app. If you don't need "sudo" you can set: use_sudo false. My ubuntu settings for users: sudo:x:27:oliver,deployer,michal –  quatermain May 17 '12 at 6:54
add comment

When deploying to an ec2 instance you will not have sudo rights with the ubuntu user.

Change this:

set :use_sudo, true

To this:

set :use_sudo, false

share|improve this answer
add comment

Your Answer


