Suddenly, Capistrano began to return a SSH issue:
** [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: staging.myserver.com (Net::SSH::AuthenticationFailed: root) connection failed for: staging.myserver.com (Net::SSH::AuthenticationFailed: root)
My deploy.rb contains:
require 'capistrano/ext/multistage'
ssh_options[:forward_agent] = true
ssh_options[:keys] = ["myserver_rsa"]
set :stages, ["staging", "production"]
set :default_stage, "staging"
set :scm, "git"
set :application, "myapp"
set :repository, "git@bitbucket.org:project/myapp.git"
set :use_sudo, false
set :deploy_via, :remote_cache
and at my config/deploy/staging.rb
server 'staging.myserver.com', :app, :web, :db, primary: true
set :branch, 'staging'
set :rails_env, "staging"
set :deploy_to, "/var/rails/#{application}"
set :user, "root"
set :password, "my_triple_check_password_login"
set :domain, "staging.myserver.com"
Tests made by me before posting here:
Try to login via ssh (ssh -v staging.myserver.com) => Logged successfully without prompt my password. (using myserver_rsa key)
Agent Forward => Enabled in server and in local
Try to login via ssh without keys: => prompted for password. Copy and paste it from staging.rb and logged perfectly.
Change server root password. => Try to login with new password via ssh root@... worked nice. but via capistrano, fails.
Run in IRB a Net SSH script to login. => Logged in and return a
hostname
result from bash.
This issue starts yesterday suddenly. I really don't have more ideas :/
First of all, nothing was change at server either Cap deploy configs.
Thanks!
This error is due to the authentication failure. Capistrano can't connect to the deploying server with given username and password. I already done the deployment for a server and I am now deploying to a New server. Then I got this error.
It prompted me to give the password for new server. I entered the new server password. But its showing this error.
I changed the domain here
But forgot to change the username here in my deploy.rb
After giving the correct username and password it works perfectly!
I found!
In my
/etc/ssh_config
root section I had:I was need to create a section to my staging environment:
and edit my
config/deploy.rb
to add:default_run_options[:pty] = true
Aaaaaaaaand it's works!