August 16, 2022

SSH tunnelling for fun and troubleshooting

SSH tunnelling for fun and troubleshooting
Photo by MontyLov / Unsplash

If you're creating or testing a service on a headless server it can often be useful to see what it looks like on the localhost for configuration or before you commit to trying it.

I've been migrating my old bare metal installs to containerised services on a different host recently and have found just such a use case.

You can local forward a single port over SSH like this:

ssh -L 8080:remotehostname:80 [email protected]

Now if you point your web browser at http://localhost:8080/, you should see the contents of the remote server as it would appear from the remote machine.

This doesn't require a VPN and leaves the rest of your traffic alone, so is perfect for quick testing or access to the remote network.

There's a ton more to learn about what else SSH can do and lots more to read about SSH tunnelling here: