In a setup that I have inherited, using the command ssh user2@host2:user1@host1, I can connect to user2@host2 through user1@host1 but I don't understand how it works (where is this ssh behaviour documented?)

Furthermore, I'd like to be able to setup my .ssh/config so that I can do ssh user2@host2 and it goes directly through the host1 and I believe it can be achieved using ProxyCommand but the following is a failure:

ssh -o ProxyCommand='ssh -W %h:%p user1@host1' user2@host2
user1's password:
Received disconnect from REDACTED_IP: 11: Bye Bye
Disconnected from REDACTED_IP
ssh_exchange_identification: Connection closed by remote host

You should check your $HOME/.ssh/config for record like Host *:*. If you want to know more how it works there is good article at wikibooks about that. And for command line you use you should remove equal sign = from ProxyCommand:

ssh -o "ProxyCommand ssh -W %h:%p user1@host1" user2@host2
| improve this answer | |
  • There is nothing wrong with using = between option name and value. Your version of the command will do exactly the same as the original version, but I find the original version to be a bit more readable than yours. – kasperd Nov 20 '16 at 22:25

Well, after experimenting for some time, it appears that the software of host1 (which I did not have direct access to) is configured so that user2@host2:user1 is actually a username.

Hence ssh user2@host2:user1@host1 works.

| improve this answer | |

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.