Bookmark and Share

Understanding SSH Tunneling.

Posted: Sunday, January 11th, 2009 at 12:01 amUpdated: Friday, January 30th, 2009 at 10:08 pm

Well, one possible solution is to create VPN between you and your server or your office network. If having VPN is not possible, provided that you can ssh to your server / hosting or at least one host on DMZ network, you can do port forwarding.

So how does ssh tunneling or port forwarding works? It’s like this. You specify a port on your local computer and a destination address and port. What happens, then if you connect to your local computer at that specified port, it is as if you’re connecting to a destination address at the specified port from the computer you ssh into. For example, on SSH connect to server1, you specify 1234 local port and being mapped to a host named server2 on port 3306.

sshtunnel

So what happens is like the picture above. From your computer, you make SSH connection to server1. Once connection is established, if you connect to your local computer at port 1234, it will trigger server1 to make connection to server2 on port 3306. You may know that MySQL server is on port 3306. Therefore, suppose that server2 is not accessible from internet, you can still connect and use GUI application like SQLYog to connect to server2’s MySQL server.

What happens above is you have a local port and any connection to it is being forwarded somewhere. These kinds of SSH tunnel is called as local forwarding. Similarly, you can also have a remote forwarding. The idea is pretty much the same as local forwarding, except that once you establish SSH connection, a port on server is being forwarded to your local computer.

I hope this little introduction to SSH tunneling is clear enough for you to understand how it works. Do look at my other articles on Understanding SSH Tunneling.. As always, I welcome comments / questions / critics that will help me and other readers understand better.

Pages: 1 2

2 Responses to “Understanding SSH Tunneling.”

  1. Zack Says:

    Very helpful. I have been trying to get a grasp on this topic, and this helped clarify what the source and destination ports meant and how the ssh server fits into all of this.

    Thanks

  2. Arindam Says:

    This is helpful .. very helpful. Thanks a lot.

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.