SSH Tunneling

          0 votes
November 4th, 2008

After figuring this out I've became extremely lazy on setting on VPN servers for simple use cases. As we all know SSH provides a secure means of transferring data over the internet and another great thing about it is that we don't have to install any other software to get started!

In my case I have a private web server running in my network only accessible by members of the network at lets say IP address 192.168.0.100 on port 8080 and I need to access that service remotely. From that network I have a *nix server with SSH access  (I hear SSH servers do run on Windows too) available to the public at domain rsumilang.com.

Now all that's left to do is create the tunnel from my machine to the public SSH server so I can get to my web server. And here it is:

$ ssh -N -l me@rsumilang.com -L 8000:192.168.0.100:8080

That's it. Don't expect ssh to return you back to the command prompt, its not hanging. It'll stay open like this to keep the port forwarding alive. What this command tells ssh to do is (-N) not to execute any remote commands, just log in which is useful for port forwarding, (-l) specifies the user and host to log into, and where all the magic is done, (-L) which tells the program to forward all local traffic on port 8000 through our host to address 192.168.0.100 on port 8080. To do just that you will need to request traffic locally (localhost/127.0.0.1) to yourself on port 8000.

To spit out some useful debugging information you can append -v to the command or -vv for even more debugging information.

Share/Save/Bookmark