SSH Tunnel & Port-Forward Generator
Reach a private database, share a local app or start a SOCKS proxy, with one ssh command.
Free · No signupBuilt entirely in your browser
SSH tunnel generator
Forwards
1 of 10Forward 1
SSH server
Hostname, IP address or ~/.ssh/config alias.
Leave empty to use your SSH config or login name.
Empty uses your SSH config, otherwise 22.
Path to your private key.
A bastion to go through first, as user@host:port. Separate several with commas.
What it does
Connections to localhost:5432 on this computer go through 203.0.113.10 to localhost:5432, which is the server itself.
ssh -N \
-L 5432:localhost:5432 \
-o ServerAliveInterval=60 \
-o ServerAliveCountMax=3 \
-o ExitOnForwardFailure=yes \
deploy@203.0.113.10The tunnel stays up while the command runs. Press Ctrl+C to close it.
Then try it
- Connect with psqlUse 127.0.0.1 rather than localhost so the client connects over TCP.
psql -h 127.0.0.1 -p 5432 -U postgres
For OpenSSH in Bash or Zsh on Linux, macOS or WSL. Run it on the machine that should open the local end of the tunnel.
Built in your browser. Servers, ports and key paths are not uploaded or saved. This tool writes text; it does not open a connection.
Tunnels without the flags
Save tunnels and start them with one click.
CtrlOps keeps local, remote and dynamic forwards as named tunnels, tests them first and can bring them up when it starts. Paste a command from this page straight in.
Keep it handy
Three directions,
one letter each.
The flag names where the listening port opens: -L on your machine, -R on the server, -D as a proxy.
| Type | Syntax | Use it to |
|---|---|---|
Local -L | -L [bind:]port:host:hostport | Reach a remote or internal service from your machine |
Remote -R | -R [bind:]port:host:hostport | Expose a local service on the SSH server |
Dynamic -D | -D [bind:]port | Run a SOCKS proxy through the server |
Socket -L | -L port:/path/to.sock | Reach a Unix socket, such as Docker’s, on the server |
| Flag | What it does |
|---|---|
-N | Do not run a remote command; just hold the tunnel open. Standard for pure forwards. |
-f | Go to the background after authenticating. Needs -N or a command. |
-J host | Connect through a jump host (bastion) first. |
-o ServerAliveInterval=60 | Send a keepalive every 60 seconds so idle tunnels are not dropped. |
-o ExitOnForwardFailure=yes | Exit if a port cannot be opened, instead of staying up without it. |
How SSH tunnels work
Private services.
Reached over SSH.
What is SSH tunneling?
SSH tunneling, or port forwarding, carries a TCP connection inside an encrypted SSH session. Instead of opening a database, dashboard or dev server to the internet, you reach it over SSH, so it stays private and encrypted. There are three directions, each a one-letter flag.
Local forwarding (-L): reach something remote
The most common kind. -L opens a port on your machine and forwards it to a destination the SSH server can reach. With ssh -L 5432:localhost:5432 user@server, a database client pointed at 127.0.0.1:5432 talks to Postgres on the server. The destination is resolved by the server, so localhost there means the server itself, and 10.0.1.20 means a machine on its private network. A Unix socket works as a destination too: -L 2375:/var/run/docker.sock lets your local docker command drive the server’s Docker.
Remote forwarding (-R): expose something local
The reverse. -R opens a port on the server and forwards it back to a destination your machine can reach. ssh -R 8080:localhost:3000 user@server makes the server’s port 8080 reach your local port 3000. By default the server listens only on its own loopback; to listen on a public address, its sshd_config needs GatewayPorts clientspecified or yes. Without it, OpenSSH binds loopback anyway and does not report an error.
Dynamic forwarding (-D): a SOCKS proxy
-D turns the SSH connection into a SOCKS5 proxy. With ssh -D 1080 user@server, any browser or app set to use 127.0.0.1:1080 as its SOCKS proxy connects out from the server, as if it were on the server’s network. Use curl --socks5-hostname so names are looked up by the server, too.
Keep tunnels up, and know when they fail
Firewalls and NAT drop idle connections, so ServerAliveInterval=60 sends a keepalive every minute and ServerAliveCountMax=3 gives up after three missed replies. ExitOnForwardFailure=yes makes ssh exit when a port is already in use, instead of connecting without it. One catch: a plain -L 5432 listens on both 127.0.0.1 and ::1, so if a local Postgres already holds 127.0.0.1:5432, ssh still starts on ::1 alone. Pick a free port such as 15432 when the service also runs on your machine. For a tunnel that must come back after a drop, use autossh, or the systemd service this tool writes, which starts it at boot and restarts it on failure. To make it a two-word command, save it as a named host with the SSH config generator.
Bind address and security
A forwarded port binds to localhost by default, so only your machine can use it. Binding to 0.0.0.0 opens it to your whole network, and the service behind it then has no SSH protection in front of it. For a SOCKS proxy that means anyone on the network can browse through your server. The SSH & Security guide covers the firewall and access rules worth having before you widen a bind address.
SSH tunnel FAQ
SSH tunnels,
explained.
Use local forwarding: ssh -L 5432:localhost:5432 user@server. This opens port 5432 on your machine and forwards it to the database as seen from the server (localhost there = the server). Point your DB client at localhost:5432. Choose Local in this tool and set the ports.
Use remote forwarding: ssh -R 8080:localhost:3000 user@server opens port 8080 on the server and forwards it to your local port 3000. To let others (not just the server) reach it, the server needs GatewayPorts yes in sshd_config.
Use dynamic forwarding: ssh -D 1080 user@server opens a SOCKS5 proxy on localhost:1080. Configure your browser or app to use a SOCKS5 proxy at 127.0.0.1:1080 and its traffic routes through the server.
Idle connections get dropped by NAT and firewalls. Add -o ServerAliveInterval=60 (and ServerAliveCountMax=3) so SSH sends keepalives, and use autossh for tunnels that must auto-reconnect after a drop. This tool can generate both the keepalive options and the autossh command.
Local (-L) opens the port on your machine and forwards to a destination reachable from the server - use it to reach something remote. Remote (-R) opens the port on the server and forwards back to your machine - use it to expose something local. The rule of thumb: the flag names where the listening port is opened.
-N tells SSH not to run a remote command, so it just holds the forward open without giving you a shell. -f sends SSH to the background after it authenticates. Together, ssh -fN -L ... is the usual way to start a background tunnel.
Keep working
Tools and guides for your next step.