Port forwarding
Local, remote and SOCKS5 tunnels in Harbor, started with a session or on their own.
Port forwarding
Port forwarding (SSH tunnels) carries network connections through an SSH connection. Use it to reach a database or web app that only listens on a server’s private network, or to let a server reach something on your computer.
Types
| Type | Like | What it does | Example |
|---|---|---|---|
| Local | ssh -L |
Opens a port on your computer that reaches a host and port as seen from the server. | localhost:5432 → db.internal:5432 to use a private PostgreSQL from your computer. |
| Remote | ssh -R |
Opens a port on the server that reaches a host and port as seen from your computer. | Server port 8080 → localhost:3000 to show a server your local dev app. |
| SOCKS5 proxy | ssh -D |
Runs a SOCKS5 proxy on your computer; traffic goes out from the server. | Point a browser at localhost:1080 to browse as the server. |
Add a tunnel
- Edit the host and open Port forwarding.
- Click Add forward and choose the Forward type.
- Fill in:
- Tunnel name, so you recognize it later.
- Listen address and Listen port: where the tunnel opens. For Local and SOCKS this is on
your computer (
127.0.0.1keeps it private to your computer); for Remote it’s on the server. - Destination host and Destination port (Local and Remote only).
- Save.
Tunnels start with every terminal session to that host and stop when the last session closes.
Tunnels without a terminal
The Port forwarding page lists every host’s tunnels. Start tunnels runs a host’s tunnels on a background connection, with no terminal open, and shows their status (Running, Running in terminal, Stopped or Needs attention) and the traffic sent and received. Stop tunnels ends them. Turn on Start automatically when Harbor opens (on that page or in the host editor) to start them each time Harbor starts.
Background tunnels use the host’s saved login, and need the host (and any jump hosts) to have been trusted in a terminal first. See Host keys.
Tips
- Use a listen address of
127.0.0.1unless other computers on your network need the tunnel. - If a port is already in use on your computer, the tunnel reports it; choose another port.
- Remote forwards on other addresses than
localhostneedGatewayPortsenabled in the server’ssshd_config. - Forwards in
~/.ssh/config(LocalForward,RemoteForward,DynamicForward) are imported with the host.