Tunnels
SSH tunnelling is used to transport data over an SSH connection. In the following sections, we will look at two methods of tunnelling: local forwarding and proxying.
Local forwarding
SSH can create secure, encrypted tunnels to remote systems. This functionality is similar to what a VPN provides and can allow you to access services reachable from the remote system.
That’s powerful functionality, and with SSH, it’s actually simple to achieve. All you have to do is specify an additional argument, -L
, with the destination and the local port to bind it to when establishing an SSH session.
Imagine a remote system running an HTTP server on port 8080
. You want to access it on your laptop, on port 3000
. Here is how to accomplish that with a simple command:
ssh -L 3000:localhost:8080 user@example.org
You can now open a browser and visit http://localhost:3000/
to access the web server as if you were opening that browser on the remote system and...