Create a local port forward
Forward a local port to a remote host and port.
ssh -L 5432:db.internal:5432 bastion.example.comForward a local port to a remote host and port.
Local, remote, and dynamic SSH forwarding with practical database, web, and bastion tunnel recipes.
Local, remote, and SOCKS tunnels.
Forward a local port to a remote host and port.
ssh -L 5432:db.internal:5432 bastion.example.comForward a local port to a remote host and port.
Expose a local service on the remote host.
ssh -R 8080:localhost:3000 user@example.comExpose a local service on the remote host.
ssh -D 1080 user@example.comOpen a local SOCKS proxy for browser or CLI traffic.
Create a tunnel without running a remote shell.
ssh -fN -L 5432:db.internal:5432 bastion.example.comCreate a tunnel without running a remote shell.
Forward a local UNIX socket to a remote UNIX socket.
ssh -L /tmp/pg.sock:/var/run/postgresql/.s.PGSQL.5432 user@example.comForward a local UNIX socket to a remote UNIX socket.
Allow remote listeners to bind beyond localhost when server policy permits it.
ssh -R 0.0.0.0:8080:localhost:3000 user@example.comAllow remote listeners to bind beyond localhost when server policy permits it.
Practical DB, web, and multi-hop tunnel patterns.
ssh -fN -L 5432:postgres.internal:5432 bastion.example.comAccess a private PostgreSQL instance through a bastion.
ssh -fN -L 3306:mysql.internal:3306 bastion.example.comAccess a private MySQL instance through a bastion.
ssh -fN -L 6443:k8s-api.internal:6443 bastion.example.comAccess a private API server locally.
ssh -J bastion.example.com -L 9200:elastic.internal:9200 user@private.internalCreate a local forward through a ProxyJump bastion.
Override config-defined forwards for one invocation.
ssh -o ClearAllForwardings=yes user@example.comOverride config-defined forwards for one invocation.