Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

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.