user984621
user984621

Reputation: 48453

Capistrano cannot deploy code, because Net::SSH::AuthenticationFailed: Authentication failed

We have a Rails app that is running on Amazon AWS. We're pushing there a new code almost every day for a few months in a row.

Today, when I tried to deploy a new code there, I was given this error message:

  * 2014-02-16 13:09:51 executing `deploy'
  * 2014-02-16 13:09:51 executing `deploy:update'
 ** transaction: start
  * 2014-02-16 13:09:51 executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote [email protected]:my_bitbucket_name/project_name.git master"
    command finished in 2909ms
  * executing "if [ -d /home/deployer/project_name/shared/cached-copy ]; then cd /home/deployer/project_name/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 16958dfcee27dd9c33855ecece0013428e2c57c8 && git clean -q -d -x -f; else git clone -q -b master [email protected]:rdudacz/looky.co.git /home/deployer/looky/shared/cached-copy && cd /home/deployer/project_name/shared/cached-copy && git checkout -q -b deploy 16958dfcee27dd9c33855ecece0013428e2c57c8; fi"
    servers: ["IP"]
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deployer/project_name/releases/20140216120957; true"
    servers: ["IP"]
 ** [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: IP (Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP)
connection failed for: IP (Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP)

What happened here? Where to start with looking for the issue?

Upvotes: 13

Views: 13898

Answers (5)

Artyom Kalmykov
Artyom Kalmykov

Reputation: 390

For capistrano2 in your deploy.rb

  • net-ssh 2.9.1 set :ssh_options, { config: false}
  • net-ssh 2.9.2 set :ssh_options, { config: false, number_of_password_prompts: 0 }

Upvotes: 0

Rameshwar Vyevhare
Rameshwar Vyevhare

Reputation: 2759

Please remove old net-ssh and install updated as below, add this in your gem file or can install it on your environment specifying 2.9.2 version.

gem 'net-ssh', '~> 2.9.2'

Its works for me.

Upvotes: 0

Anbazhagan p
Anbazhagan p

Reputation: 943

I had the same problem while deploying using capistrano Net::SSH::AuthenticationFailed: Authentication failed for user deployer@IP

ssh-copy-id deployer@ip 

This will add your keys to server and you can login without password.

Upvotes: 10

user1320189
user1320189

Reputation: 33

After uninstall net-ssh 2.8.0, remove on gemfile.lock, too. It will continuously okay.

Upvotes: 0

user984621
user984621

Reputation: 48453

The problem is the gem

net-ssh

The last version (2.8.0) causes this issue. The solution is to uninstall it:

gem uninstall net-ssh -v 2.8.0

and then to add to the Gemfile its previous version:

gem "net-ssh", "~> 2.7.0"

That's it.

Upvotes: 23

Related Questions