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?


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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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