How to Create a Permanent SSH Reverse Tunnel
Secure Shell (SSH) is a protocol for securely connecting to remote computers. The OpenSSH program, installed by default on most Linux machines, implements the SSH protocol features. Some of these features include port forwarding, compression, and forwarding graphical programs. Port forwarding is commonly used to securely bypass firewalls. For example, you can open the SSH port on a remote machine's firewall and send emails to the remote server through SSH without opening the email ports. Reverse forwarding is also possible. You can forward ports on a remote machine to your local computer.
Instructions
-
-
1
Enter "sudo apt-get install autossh" in the terminal to install the required packages.
-
2
Type "autossh -nNT -R remoteport:localhost:localport user@remotehost." Replace "remoteport" with the port on the remote machine that will be forwarded to your local machine; "localport" with the port you want the remote port to be forwarded to, and "remotehost" with the IP address or host name of the remote machine.
-
-
3
Type "sudo nano /etc/rc.local" and paste the "autossh -nNT -R remoteport:localhost:localport user@remotehost" command into this file. Save the file by typing "Ctrl" and "X" and then "Y" and "Enter." This will run the command every time you reboot your machine.
-
1