postheadericon How to Create a Reverse Ssh Tunnel

Need to skirt around that pesky corporate firewall?

Or host a service while NATed?

What you need is a reverse SSH tunnel and you will be well on your way to confusing your friends trying to tell them what you’ve done.

How to Create a Reverse Ssh Tunnel

1 Server: apt-get install openssh-server

How to Create a Reverse Ssh Tunnel

2 Server: ssh-keygen

How to Create a Reverse Ssh Tunnel

3 Client: apt-get install openssh-client

How to Create a Reverse Ssh Tunnel

4 Client: ssh-keygen

How to Create a Reverse Ssh Tunnel

5 Client: ssh-copy-id user@server

How to Create a Reverse Ssh Tunnel

6 Server: Edit /etc/ssh/sshd_config as root. Change ‘#PasswordAuthentication yes’ to ‘PasswordAuthentication no’. Add ‘GatewayPorts clientspecified’ to the end of the file.

How to Create a Reverse Ssh Tunnel

7 Client: Now we create the reverse tunnel with
ssh -R 10.0.0.111:5555:127.0.0.1:4444 user@10.0.0.111 -R makes the tunnel reversed 10.0.0.1 is the ip address of the interface on your server that is facing the Internet 5555  is the servers port to listen on. 4444 is the port to forward to on your client.

How to Create a Reverse Ssh Tunnel

8 Now you can open ports on the server to the Internet and forward them through your tunnel to your client.

Leave a Reply