- Unsupervised Learning
- Posts
- How to Connect to a Local Port on a Remote SSH Server
How to Connect to a Local Port on a Remote SSH Server
![73189374](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/2f399604-7d42-4f64-b763-4cd027a025dd/73189374.jpg)
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](https://media.beehiiv.com/cdn-cgi/image/fit=scale-down,format=auto,onerror=redirect,quality=80/uploads/asset/file/ce69b23c-7dcf-44ef-8f55-b0f8f4410ac2/Screen-Shot-2017-04-13-at-5.49.26-PM.png)
Hope it helps someone.