Jeevan Dongre
Jeevan Dongre

Reputation: 4649

capistrano with ubuntu ec2 instance to deploy ruby on rails

I am trying to implement ruby on rails app using Capistrano, I am running apache rvm in the staging server and nginx REE version in production server. I am using git also. I have been try to integrate Capistrano but I am getting the this error

(Net::SSH::AuthenticationFailed: ubuntu)

Here is my deploy.rb file

set :application, "capify"

# The directory on the EC2 node that will be deployed to
set :deploy_to, "/home/ubuntu/apps/#{application}"

set :keep_releases, 3

# deploy with git
set :scm, :git
set :repository,  "[email protected]:username/capify.git"
set :git_shallow_clone, 1
set :branch, "master"
set :use_sudo, false

set :user, "ubuntu"
ssh_options[:keys] = ["/path/tp/key.pem"]
ssh_options[:forward_agent] = true
default_run_options[:pty] = true

# The address of the remote host on EC2 (the Public DNS address)
set :location, "ip"

# 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"
end

desc "Symlinks the database.yml"
task :symlink_db, :roles => :app do
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end

end

Unable to figure the exact problem and the methods to integrate capistrano.

Upvotes: 1

Views: 1751

Answers (1)

Tigraine
Tigraine

Reputation: 23648

It seems simple: Capistrano does not prompt for passwords when deploying but rather expects your SSH key to authenticate you on the target server.

It seems like the user you are trying to deploy as (ubuntu) can't be authenticated because of this.

Try adding the contents of your ~/.ssh/id_rsa.pub to the servers: /home/ubuntu/.ssh/authorized_keys file.

If you can ssh into your machine without getting prompted for a password it is working

Update: In your case you are using the ssh_options[:keys] to define another key to be used for SSH authorization. You could either remove that directive to default to your standard ssh key (the one in ~/.ssh/id_rsa.pub) or add that other key you are specifying to the authorized_keys file on your server.

I suggest you try it without the ssh_options[:keys] option :)

Upvotes: 2

Related Questions