Termini
Port forwarding
Port forwarding sends network traffic through your SSH connection. In a host’s editor, Port Forwarding lists its tunnels; add one with +.
The three kinds
Section titled “The three kinds”| Kind | Like | Example | What it does |
|---|---|---|---|
| Local (-L) | ssh -L 8080:localhost:80 |
bind 127.0.0.1:8080 → target localhost:80 |
http://localhost:8080 on your Mac reaches port 80 on the server |
| Remote (-R) | ssh -R 2222:localhost:22 |
bind 0.0.0.0:2222 → target localhost:22 |
port 2222 on the server reaches port 22 on your Mac |
| Dynamic SOCKS (-D) | ssh -D 1080 |
bind 127.0.0.1:1080 |
a SOCKS proxy on your Mac that sends traffic out from the server |
Fields
Section titled “Fields”| Field | |
|---|---|
| Bind host / port | where the tunnel listens — on your Mac for local and dynamic, on the server for remote |
| Target host / port | where traffic goes (not used for dynamic) |
| Enabled | turn a tunnel off without deleting it |
| Open on connect | open it automatically when you connect to the host (on by default) |
| Notes | what it’s for |
Tunnels close when the host’s connection closes.
Common uses
Section titled “Common uses”- A database behind a firewall: local
127.0.0.1:5433→localhost:5432, then point your database client atlocalhost:5433. - A web admin panel bound to localhost: local
127.0.0.1:8080→localhost:8080. - Browse as the server: dynamic
127.0.0.1:1080, then set your browser’s SOCKS proxy tolocalhost:1080.