Here’s a little trick that I learned how to do the other day while at work. I’ve done this before using ssh in a linux terminal but hadn’t had the chance to actually do it from a windows box using PuTTY.
Objective
To access a web server (on a remote linux box) which is listening on port 80 through an ssh connection. We want to access the web server through port 10001 on the localhost. This can be accomplished by mapping localhost’s port 10001 to port 80 on the remote host.
Here’s a diagram that attempts to represent what’s going on with the ports, the hosts, and the ssh connection.
Setup
In this scenario we have 2 hosts, the local host (i.e. localhost) and the remote host (homer). Running PuTTY on the localhost, we specify that we want to login to homer as a user on that system, i.e. root, for example. It doesn’t have to be root, this just happens to be the user that I’m using in this example.
Next in the PuTTY Configuration dialog box, expand the category SSH, and select the category Tunnels. In Tunnels’ configuration, specify the Source port, 10001, and the Destination, homer:80. Then click the Add button.
At this point the PuTTY Configuration dialog should look like this, after clicking the Add button. Now go ahead and connect to the remote host by clicking the Open button, and login as you’d normally would to the remote host.
After successfully logging in, you should be sitting at your shells prompt.
Now in your web browser put in the URL http://localhost:10001/, and you should see the front page for the web server running on the remote host, homer.
NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.






