SSH & Keys
SSH Tunnel Builder
SSH Tunnel Configuration
Tool features
All three directions
Correct port syntax
Copy-ready command
Advanced options
What SSH port forwarding is & how it works
SSH port forwarding — tunnelling — carries an ordinary TCP connection inside an SSH session. Because the SSH connection is already authenticated and encrypted, anything routed through it inherits both. It is how you reach a database that only listens on localhost, or a service on a private network with no public address, without opening a firewall port.
There are three directions. -L (local) opens a port on your machine that emerges on the server's side of the network. -R (remote) does the reverse, exposing something on your machine to the server. -D (dynamic) turns the session into a SOCKS proxy that can reach anything the server can. This tool assembles the exact command for whichever you pick.
-L 5432:localhost:5432 — your port 5432 reaches the database as the server sees it.-R 8080:localhost:3000 — the server's port 8080 reaches your local dev server.-D 1080 — a SOCKS5 proxy on your machine, routing through the server.-N runs no remote command (tunnel only); -f drops it to the background.How to use this tool
Port and a private key path if the server needs them.-f -N to background it, or put the forward in ~/.ssh/config to make it permanent.Related tools
Frequently asked questions
ssh -L 5432:localhost:5432 user@server means "connect to port 5432 on my machine and you reach port 5432 as the server sees it" — so localhost in that command refers to the server, not you. Then point your client at localhost:5432.sshd binds remote forwards to the loopback interface, so only the server can use them. To expose the port more widely, the server needs GatewayPorts yes (or clientspecified) in /etc/ssh/sshd_config. That is a server-side setting — you cannot enable it from the client.ServerAliveInterval 60 so the client sends a keepalive every minute, and consider a supervisor such as autossh for tunnels that must survive network changes and reconnect on their own.-N tells SSH not to run a remote command — you want the tunnel, not a shell. -f pushes SSH into the background once authentication finishes. Together, ssh -f -N -L ... is the standard way to start a tunnel without tying up a terminal window.~/.ssh/config under the host block — LocalForward 5432 localhost:5432 — and it opens automatically whenever you connect to that alias. For a tunnel that must always be up, run it under a process supervisor such as systemd or autossh.0.0.0.0 instead of localhost makes it reachable by anyone who can reach that interface. Bind to localhost unless you specifically intend to share it, and remember that server operators can disable forwarding entirely with AllowTcpForwarding no.