Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to get ssh key forwarding to work so that I can ssh to a server and then use my local private key to then access another server.

All works fine if I do

ssh -A -i <identify file> user@server.com

However, if I move the identity file directive to the ssh config file:

Host server.com
    IdentityFile <identity file>

Then, I can still log in to the first server with

ssh -A user@server.com

(so I know that the IdentityFile directive is correct) but the key forwarding doesn't work any more. It's like the -A flag is ignored. Does anyone know how to get his working?

share|improve this question
I tried adding a few relevant-looking flags to the config file: IdentitiesOnly no IdentityFile <ID file for the seconds server> ForwardAgent yes It didn't seem to make a difference. –  Fasaxc Aug 10 '12 at 22:12
Run with the -v (verbose) flag to see what's going on. You should see a line along the lines of debug1: Offering RSA public key: /home/<YOURNAME>/.ssh/id_rsa. –  larsks Aug 11 '12 at 0:39
Are you using an SSH agent? –  mgorven Aug 12 '12 at 5:31
Yes, I believe Ubuntu starts ssh-agent by default at login. It's running according to ps -A. –  Fasaxc Aug 15 '12 at 15:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.