Reverse SSH tunneling

A very simple post about setting up reverse SSH tunneling. This is how to get to a machine that maybe behind a firewall, when you are not behind the firewall (though you need to be to set it up!)

We have two machines: is our machine that is behind the firewall, and is our machine that we are working on. Ordinarily, we can ssh from to but we can not ssh the other way, because is behind a firewall.

First, we ssh from to and tell to listen on one of the unused ports: $ ssh 44444:localhost:22

This will log you into like normal. Now, we switch over to and ssh to However, since we have the connection open, we tell to just ssh to port 44444: $ ssh -p 44444 localhost

This will log you back into and you are connected! Reverse tunneling in a snap