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: remote.edu
is our machine that is behind the firewall, and local.edu
is our machine that we are working on. Ordinarily, we can ssh
from remote.edu
to local.edu
but we can not ssh
the other way, because remote.edu
is behind a firewall.
First, we ssh from remote.edu
to local.edu
and tell remote.edu
to listen on one of the unused ports:
remote.edu:~ $ ssh 44444:localhost:22 redwards@local.edu
This will log you into local.edu
like normal. Now, we switch over to local.edu
and ssh
to remote.edu
. However, since we have the connection open, we tell local.edu
to just ssh
to port 44444:
local.edu:~ $ ssh -p 44444 localhost
This will log you back into remote.edu
and you are connected! Reverse tunneling in a snap