← Knowledge Base
VPNReference note1 min read · updated 2026-11-27

SSH tunnels: reach a private service safely

Local, remote and dynamic forwarding with ssh, and when this is enough instead of a VPN.

sshtunnelforwarding
ssh -L 8080:localhost:80 user@server          # local: open http://localhost:8080 to reach the server's port 80
ssh -L 5432:db.internal:5432 user@bastion     # through a jump host to a private database
ssh -R 9000:localhost:3000 user@server        # remote: expose your local port 3000 on the server's 9000
ssh -D 1080 user@server                       # dynamic: a SOCKS5 proxy on localhost:1080
ssh -N -f -L 8080:localhost:80 user@server    # no shell, run in the background
ssh -J bastion user@private-host              # jump host shortcut

This is handy to reach an admin page that is bound to 127.0.0.1 without exposing it to the internet. For permanent or multi-service access a VPN (WireGuard) is easier to manage. Keep tunnels key-authenticated and restrict who may forward.