Super User is a question and answer site for computer enthusiasts and power users. 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

I would like to ssh-forward id_rsa keys from localhost through server 1 to server 2

  1. On the localhost computer I have the id_rsa keys which get added to ssh-agent for forwarding to a remote server.

  2. Then I would like to be able to add those forwarded keys from my localhost to the remote sever 1 ssh-agent as well ready to forward onto remote server 2.

Effectively I want to use the id_rsa keys on my localhost and add them to the forwarding on the remote server 1.

share|improve this question

Using a tunnel, the connection will be: localhost > server1 > server2.

To create an ssh-tunnel and transfer the key: First, (if needed) copy your rsa key from localhost to server1

ssh-copy-id user1@server1

After that you can:

  1. create tunnel from port 2222 (or any port over 1024) on localhost to port 22 on server2
  2. copy the key over the tunnel
  3. log in on server2 over the tunnel

ssh user1@server1 -L 2222:server2:22

ssh-copy-id -p 2222 user2@localhost

ssh -p 2222 user2@localhost

From server2's perspective the connection will then be from server1's IP using the keyfile from localhost.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .