Tunneling

Local forward

ssh -N -L 8080:localhost:80 user@host

Forwards a local port. The target is a port on the remote. Listens on port 8080 and reaches port 80 on host; see ssh(1).

Remote forward

ssh -N -R 9000:localhost:5432 user@host

Forwards a remote port. The target is your machine. Listens on port 9000 on host and reaches port 5432 locally; see ssh(1).

SOCKS proxy

ssh -N -D 1080 user@host

Routes via SOCKS. Traffic goes through a SOCKS proxy. Opens a local proxy on port 1080 and sends traffic through host; see ssh(1).

Background tunnel

ssh -fN -L 8080:localhost:80 user@host

Starts a background tunnel. The tunnel runs in the background. -f backgrounds it and -N skips the remote shell; see ssh(1).

0 Comments for this cheatsheet. Write yours!