Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Do I need to have a private key on the interim server pc2?

I want to connect to pc3 through pc2 without any possibility for pc2 to intercept or forge traffic from pc1 to pc3. I am on pc1.

There is following configuation on pc1.

Host pc2
     HostName pc2
     User user2
     ProxyCommand ssh -W %h:%p user@pc3

How can I setup what public/private key pair will be used for pc3 when connecting to it through pc2?

share|improve this question
up vote 1 down vote accepted

Just set this in your ~/.ssh/config

Host *
  ForwardAgent yes

Most servers have AllowAgentForwarding on by default so it will automatically forward keys when possible.

share|improve this answer

The ssh -i option specifies the location of the identity file you want to use. The -A option forwards credentials, so loading the key you want into ssh-agent via ssh-add may also do what you want without having to explicity list a key in the config file.

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.