Josh Halickman

SSH Tunneling Made Easy

This is going to be a quick post but every time I need to do this I always forget how so I wanted to put it down someplace.

Every now and then you need to make a connection from Computer A to Computer B but Computer A can not make a direct connection to Computer B (because of a firewall or something similar). If you have a computer that A can reach and that can reach B, which we will call the Middle Man, then you can set up a tunnel through the Middle Man from A to B.(See the diagram below)

If you run the following code below on Computer A, and then connect to localhost instead of Computer B, your traffic will be routed through the Middle Man and to Computer B.

ssh -f -L [port_#]:[computer_b_hostname]:[port_#] [username]@[middle_man_hostname] -N