Tunneling Through a Remote Firewall Using SSH Commands

If you’re deal­ing with sys­tems behind a fire­wall it’s almost inevitable that you will need to tun­nel into those sys­tems from time to time.  For­tu­nate­ly, there are some quick & easy com­mands to accom­plish this.  In this exam­ple, we are going to use a Mac OSX or linux-based sys­tem, to gain access to a web server’s port 80 on a fire-walled server.

Let’s say the domain of the remote server is dfrn.net, the fire-walled server has an IP address of 192.168.1.100 and the fire­walled server has a web server at port 80.  We need to choose an unused port on our own sys­tem, in this case we’ll use 2020.

So our side of the tun­nel is going to be http://localhost:2020/ and the oth­er side of the tun­nel will be http://192.168.1.100:80/.

ssh root@dfrn.net -L 2020:192.168.1.100:80
 
root@dfrn.net's password:

So, now port 80 on the fire-walled server will be acces­si­ble by sim­ply point­ing your web browser to http://localhost:2020/.  To ter­mi­nate the tun­nel, sim­ply exit the shell.

Leave a Reply

Your email address will not be published. Required fields are marked *