How to Connect to a Local Port on a Remote SSH Server

April 13, 2017
73189374

If you ever have a web server (or other type of server) running on a remote Linux box, and you want to connect to it using your local system, here’s how you do it.

ssh -i ./.ssh/key.pem -N -L 8081:localhost:8000 user@host

This reads as:

  • Authenticate using a key.

  • The port you’re listening on on your local system is localhost:8081.

  • The port you’re listening on on your remote Linux box is localhost:8000.

  • You’re connecting as user@host.

Then you just go to your browser and browse to: localhost:8081, and you’ll be touching the local port 8000 on the remote box.

screen-shot-2017-04-13-at-5.49.26-pm

Hope it helps someone.

supporting = loving

For 29.4836 years I've been creating ad-free technical tutorials and essays here. 3,037 pieces and counting.

It's a one-person effort that's also my livelihood. If it makes your day easier or more pleasant in any way, please consider supporting the work with a monthly or one-time donation.

It helps me make more content, and is deeply appreciated as well. 🫶🏼