Capistrano error : could not connect to ssh-agent


#1

Hello!
I’m using Bedrock with Capistrano deploys.
When I use command bundle exec cap staging deploy:check I get an authentication error :

...
D, [2015-05-09T15:39:53.878464 #15636] DEBUG -- net.ssh.authentication.session[1e34a58]: trying publickey
D, [2015-05-09T15:39:53.878464 #15636] DEBUG -- net.ssh.authentication.agent[1e30d2c]: connecting to ssh-agent
E, [2015-05-09T15:39:53.879447 #15636] ERROR -- net.ssh.authentication.agent[1e30d2c]: could not connect to ssh-agent
E, [2015-05-09T15:39:53.879447 #15636] ERROR -- net.ssh.authentication.session[1e34a58]: all authorization methods failed (tried publickey)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@SERVER_IP: Authentication failed for user deploy@SERVER_IP
Tasks: TOP => git:check => git:wrapper

Capistrano could not connect to ssh-agent on my server.

But I can log in on my server via SSH like this ssh deploy@SERVER_IP without password. I dit all the instructions in Capistrano Authentication & Authorisation Docs page, so I can use command like me@localhost $ ssh deploy@one-of-my-servers.com ‘hostname; uptime’.

If I enter command ssh -A deploy@SERVER_IP 'env | grep SSH_AUTH_SOCK' I get result

SSH_AUTH_SOCK=/tmp/ssh-UweQkw7578/agent.7578

Here is my deploy.rb file :

set :application, 'dyxovka-special'
set :repo_url, 'git@github.com:tanzoor/dyxovka-wp-theme.git'
set :branch, :master
set :tmp_dir, '~/tmp'
set :log_level, :info
set :linked_files, fetch(:linked_files, []).push('.env')
set :linked_dirs, fetch(:linked_dirs, []).push('web/app/uploads')

Here is my staging.rb file :

set :stage, :staging
set :deploy_to, -> { "/var/www/vhosts/project/dev" }
server 'SERVER_IP', user: 'deploy', roles: %w{web app}
set :ssh_options, {
  user: 'deploy',
  keys: %w('/c/Users/alexander/.ssh/id_rsa'),
  forward_agent: true,
  auth_methods: %w(publickey),
  verbose: :debug
}
fetch(:default_env).merge!(wp_env: :staging)

Apache’s agent forwarding agent instruction is enabled in sshd_config file : AllowAgentForwarding yes

What should do with my config files to make my deploy work?

Windows 8.1
Ruby 2.2.0
Capistrano 3.2.1
Git Bash


#2

Try following this article as well as it has some tips about SSH forwarding set up/debugging.