SSH Port Forwarding Examples
SSH Port Forwarding or SSH Tunnel
Local and Remote forwarding connects ports on two machines over SSH connection (tunnel).
Local Forwarding
Local forwarding -L
creates a listener on the local machine (current shell) and forwards traffic to the remote host.
ssh -L 8001:localhost:80 remote.example.com
Remote Forwarding
Remote forwarding -R
creates a listener on the remote machine (requested shell) and forwards traffic to the local host.
ssh -R 8004:localhost:8003 remote.example.com