My setup is like this:

[local machine] --> [university network] --> [local machine in university network]
   [machine1]   -->       [machine2]     -->              [machine3]

I have setup passwordless access with ssh-keygen. When I'm on machine1, I can type ssh user2@machine2 and I am promptly connected. I can move on from there to type ssh user3@machine3 and I'm in.

I now want to be able to type ssh machine3 on machine1 and directly connect the the third machine. I wrote the following .ssh/config file:

Host machine3
    Hostname machine3
    ProxyCommand ssh user2@machine2 -W %h:%p
    User user3
    IdentityFile ~/.ssh/id_rsa.pub
    IdentitiesOnly yes  

However, now I am always prompted for the password for user3. If I type it in, I'm connected, so the tunneling works. How can I skip typing in the password for user3?

Machine1 is Windows10 Pro (I'm using the ssh command in the power-shell). Machine2 runs Ubuntu 20.04.2 LTS (Focal Fossa) Machine3 runs Linux Mint 20.3 Una

  • 1
    Hint: your setup is not equivalent to connecting from 1 to 2 and from 2 to 3 (like in the manual method). It's connecting from 1 to 2 and from 1 to 3. Credentials for 3 must therefore come from 1. Can you take it from here? Commented Jun 30, 2022 at 17:26
  • @KamilMaciorowski so I need to copy my public key from machine1 to machine3? Commented Jun 30, 2022 at 17:52
  • I think so, but I'm not going to actually test this and write an answer. If you succeed, please you write an answer. There is no need to mention my input in the answer. Commented Jun 30, 2022 at 17:58

1 Answer 1


As hinted in the comments, I mistakenly assumed, that I would connect with a "stop" on machine2. However, that's not the case. The solution is to copy the ssh public key both to machine2 and machine3 from machine1.

You must log in to answer this question.

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