SSH Reverse Tunneling

This is where you create a tunnel that allows other people to get to you. Typically it's used to bypass NAT when you can't establish port forwarding. 

                ------N------>
  Private Server<--------A----------- Public Server
                ------T------>     ^
                                   |
                                  You



A common use is to ssh to remote server that you can reach, but that can't reach you, and open a port on that server that links back to your own sshd. This allows anyone on that server to connect to your local sshd, effectively reaching you through NAT, Firewalls and other obstacles.

# On the machine behind NAT
ssh -R 7000:localhost:22 allen@public.ssh.host

# Here are what the options mean
       -R : Tells SSH this is a reverse tunnel
     7000 : The port on the public host you're opening
localhost : Localhost is what you're connecting back to
       22 : The port on localhost that the public host connects to (sshd uses port 22)


Add to that the options -f -N to launch it in the background without a shell. However, to make this work past a reboot and re-initiate a dropped connection, check out autossh. That's what really creates a solution


http://www.thegeekstuff.com/2013/11/reverse-ssh-tunnel/

Comments