SSH port forwarding
ssh Is such a powerful tool. One the best techniques it enables, in my opinion, is forwarding remote or local ports. Leveraging this ability allows one to shift access from various parts of a network securely.
An example eh#
Imagine a world where you’re running a web application on a remote server where the web application is server locally only.
Maybe it doesnt need to be openly available. Maybe it doesn’t need to be accessed often. Maybe limited access best reduces the risk to the security posture. legacy cough cough Using ssh, we can forward this port to our system, accessing it as if it were local. ssh ensures traffic is encrypted and transported through the established tunnel.
|------REMOTE-------| <<<ssh tunnel>>> |------ME-----------|
| [my local app]:80<====================>8000:[local port] |
|-------------------| <<<ssh tunnel>>> |-------------------|
TL;DR, the remote application’s port 80
is served on the local port 8000
. How neat is that?
What’s the point here#
I’m not here to regurgitate what others have better explained but to share one of my favorite references. I can say every time, without exaggeration, I look to use a port forward I always refer to this specific stackexchange post. The author Erik explains the concept best with these exquisite drawings.
Local port forwarding#
local: -L Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.

Using local port forward
Remote port forwarding#
remote: -R Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.

Using remote port forward
props to Erik for these! I couldn’t give you enough upvotes on stackexchange, but I could spread the word.
-daryl