Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I find out whether an SSH connection has been established with or without agent forwarding?

I'm trying to do the following:

ssh-add -D (delete all stored keys)
ssh --vvv something
ssh-add (adding key)
ssh --vvv something

and compare output, but I can see only subtle differences.

share|improve this question
add comment

migrated from stackoverflow.com Aug 16 '11 at 13:00

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 5 down vote accepted

When ssh agent forward is enabled on the client (ForwardAgent yes on ~/.ssh/config) and is also enabled on the remote server AllowAgentForwarding yes, when logging to the remote server the environment variable SSH_AUTH_SOCK should exist. Then if you log into another server (you public key must reside on this third server) you should not be prompted for any password.

To clarify:

home$ ssh-add
Enter passphrase ...
Identity added ...
$ ssh  hostA
hostA$ env | grep SSH_AUTH_SOCK
SSH_AUTH_SOCK=/tmp/...
$ ssh hostB
hostB$
share|improve this answer
    
The ssh-add is what did the trick for me. I'd been working for months not knowing about that. Then I switched desktops from Unity to LXDE and agent key forwarding stopped working. –  Mark Hudson Sep 26 '12 at 23:04
    
@MarkHudson For some reason when running LXDE you have to run ssh-add every time you open a new console window. So I added that command line to the end of ~/.bash_profile, and now the authentication agent forwarding works every time transparently! –  Paul Bernal Feb 20 at 16:28
    
@PaulBernal You shouldn't really need to do that, I imagine you don't have ssh-agent set up correctly. See mah.everybody.org/docs/ssh –  Michael Mrozek Feb 20 at 17:37
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.