Saturday, November 20, 2010

Allowing multi-hop ssh

If you are trying to reach a server only accessible through another server, you will need to use ssh twice. This might cause mild irritation. Luckily, there is a recipe that can make things easier.

Assuming we are trying to reach hostnameB through hostnameA, add the following lines (after you put appropriate values for hostnames) to your SSH configuration in ~/.ssh/config

Host hostnameA
ProxyCommand ssh hostnameB nc hostnameA 22

For this to work, netcat needs to be installed on hostnameB, but many new systems have it, so you may have that too. Now, if you type, "ssh hostnameB" automatically you will first ssh to hostnameA and then hostnameB.

1 comment:

  1. BlueHost is ultimately the best hosting provider with plans for all of your hosting requirements.