How to chain SSH tunnels using PuTTY

Here’s a simple tutorial of how to setup a chained SSH tunnel with two SSH hosts.

  1. Open PuTTY and connect to your first (nearest to you) ssh node
  2. In the console, connect to your final ssh (which IP will be shown as an exit of chained tunnel) like this:
    ssh -CfNg -D 127.0.0.1:8787 user@hostname
  3. Right click putty title bar for context menu and click Change settings, like the following screenshot:putty config for chain ssh tunnel
    This settings means, PuTTY will listen on your local machine port 7777, and forward everything to 127.0.0.1:8787 on the first ssh server. Since in step #2 we have 127.0.0.1:8787 already there listening as a socks5 tunnel, the chain SSH tunnel is complete.

chain ssh tunnel structure

Picture provided by ditaa.org using a nice ASCII2Graph tool called ditaa

If you understand how to chain SSH tunnel using two ssh nodes, it’s easy to expanding it to three or more.

Comments