SSH ignores my ForwardAgent configuration?

I'm trying to configure Capistrano for the webapp I'm working on, and I'm having trouble sending an agent to work.

Here is my ~/.ssh/config :

 Host rs Hostname <ip of my server> ForwardAgent yes User root 

And I don’t think that the default settings override anything, since ForwardAgent is never mentioned there (except for the commented line).

Here is what happens when I usually use SSH:

 $ ssh -v deploy@ <server> OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /Users/ulyssecarion/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 102: Applying options for * -- snip -- debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.8.0-29-generic x86_64) 

If I force SSH to allow the forwarding agent with the -A flag, I can make it work:

 $ ssh -Av deploy@ <server> OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /Users/ulyssecarion/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 102: Applying options for * -- snip -- debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: Requesting authentication agent forwarding. # Note this additional line here debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.8.0-29-generic x86_64) 

(Note that in the logs of the second example there is an additional line indicating that the forwarding agent is requested.)

Is this normal, or am I doing something wrong? Thanks in advance!

+7
ssh
source share
2 answers

This block

 Host rs HostName <ip of my server> ForwardAgent User root 

only applies if your ssh call looks like

 ssh rs 

in this case ssh knows what should be used instead of "rs". In your conversation

 ssh -v deploy@ <server> 

all that you use because <server> does not match "rs" (since only the literal string "rs" will match), so the block is not applied.

The argument for the Host parameter must be a template that matches the host name that you are actually using on the command line.

+12
source share

ServerFault has excellent ssh agent forwarding setup information. https://superuser.com/questions/168933/extra-configuration-required-for-ssh-agent-forwarding

One thing I want to point out is that the ssh configuration file on the server can be commented on by ForwardAgent, but at least in my configuration file it does list the default ssh values. It seems that for some versions of openssh you need to set the AllowAgentForwarding parameter on the server. I found this article really useful https://help.github.com/articles/using-ssh-agent-forwarding

How to check if ssh agent forwarding works by looking at the $ SSH_AUTH_SOCK environment variable.

echo "$ SSH_AUTH_SOCK"

+1
source share

All Articles