Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My scenario:

I have Server A at home, and Server B at my parents house. I also have Laptop A and Laptop B at home. I do all sorts of strange ssh hops - I might connect Laptop A -> Server A -> Server B. Or Laptop B -> Server A -> Laptop A. Or Server A -> Server B

I've got keychain set up on all of these machines, and like a good security-conscious geek, I have

eval `keychain --clear`

in my .zlogin file.

My problem is that even though I unlock my keys on Laptop A, once I've connected to Server A it tries to use the keychain/ssh-agent on Server A, so I have to unlock those keys, too. I've got ForwardAgent setup on all of these machines as well. What I would prefer to happen is something like this:

  • Login to Laptop A
  • Unlock Laptop A keys
  • ssh to Server A
  • ssh to Server B - using keys from Laptop A.

How can I do this?

share|improve this question

This doesn't directly answer your question but it does give you an alternative option to consider that may help you out. I typically setup my $HOME/.ssh/config file like so:

IdentityFile ~/.ssh/my-computers

# infrastructure
Host lap1
    User sam
    #PubkeyAuthentication no
    ProxyCommand ssh sam@my.dom.com nc lap1.internal.local %p

Then when I want to connect to my lap1.internal.local system when I'm out and about I just do an:

ssh lap1

I typically ssh-copy-id my public keys to other servers that I want to login to. Let me know if you'd like me to elaborate.

share|improve this answer

Your Answer


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.