Cheatsheet Pages / SSH Cheatsheet

How to run an SSH tunnel in the background — -fN

You need the tunnel, not a shell — and it should fail loudly if the port cannot be bound.

Every flag and config keyword was checked against the OpenSSH 9.6 man pages, and the config examples were parsed for real with ssh -G.

ssh -fN -o ExitOnForwardFailure=yes -L 8080:localhost:80 deploy@example.com
# -f: background after auth   -N: no remote command, tunnel only
# ExitOnForwardFailure: exit with an error if the local port can't be bound,
# instead of "working" silently with no tunnel

Good to know

-f backgrounds after authentication, -N runs no remote command. ExitOnForwardFailure makes ssh exit with an error instead of silently 'working' with no tunnel.

SSH Cheatsheet one-page card — commands that actually work
The full one-page card — SSH Cheatsheet. Get the complete cheatsheet on GitHub