Bluish Coder

Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.


SSH provides the ability to tunnel network connections over the encrypted SSH session. This is useful for encrypting what would otherwise be plain text communications or working around restrictive firewalls by tunnelling over an allowed port.

The format of the SSH command to tunnel is:

ssh -L <local-port>:<remote-host>:<remote-port> -N

local-port is the port you want to expose on the client machine. This is the port that client programs will connect too. remote-host and remote-port are the destination host and port that you are tunnelling too.

By connecting to localhost:local-port the data is tunneled to remote-host:remote-port via the server ''. '' will need to be able to access remote-host and remote-port. Often remote-host is the same as the SSH server,

The remote-host name or IP is resolved from the point of view of so using or localhost as remote-host will actually be ''.

As an example, if you have a webserver running on '' that is bound to the localhost interface only then external applications can't connect to it. You can however via a tunnel:

ssh -L 8080: -N

Connecting to port '8080' on the client will connect to the port 80 webserver on as seen by - in this case itself.