Linux tricks, one-liners & shell magic
← Back to all tricks
SSH tunnel — forward a remote port locally

Access a service running on a remote server as if it were local. Useful for databases, dev servers, etc.

bash
$ # Forward remote port 5432 to local port 5432: ssh -L 5432:localhost:5432 user@remote-host # Persistent background tunnel (no shell): ssh -fNL 8080:localhost:80 user@remote-host
tunnelvision2026-04-19
Delete this trick? This cannot be undone.