ssh -L 5432:localhost:5432 user@server

Category: Networking

ssh -L 5432:localhost:5432 user@server

Forward local port 5432 to remote PostgreSQL

Local port forwarding: connections to your local port 5432 are tunneled through SSH to the remote server and forwarded to localhost:5432 there. Use to securely access a database (or any service) on a remote server that isn't exposed to the internet.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.