All Linux HowTo's Security HowTo's

SSH Tunnelling – Access services behind a firewall indirectly

Share This:

This one-liner illustrates how to use SSH to tunnel through a firewall that allows only SSH. In this example, we’ll access the website on the other side of that server.

Why do this? If the remote server “remote.server” has a firewall on it or between your workstation and that server and you want to access a web-site on the remote.server, you will have trouble unless you use a very nice feature of SSH – tunnelling.

ssh -L 8080:localhost:80 myuser@remote.server -p 22

The above is saying: use SSH and do a local redirection from port “8080” to the server “remote.server” on port “80” using the SSH server’s port 22. Port 22 is default but you can change it to be whatever port the “remote.server” is listening on for SSH sessions.

So direct your web browser to the following to see the website on the “remote.server” server.

http://localhost:8080/

Leave a Reply

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