Local port forward in SSH
How to access a service behind a gateway in SSH.
Tell the gateway to forward a service port from the source to a port on my local computer.
ssh -L "destination local port":"source host":"source port" -N "gateway-user"@"gateway host" -g
Example 1. Forward web interface on hostB, who is behind hostA, to port 8080 on my local machine:
ssh -L 8080:hostB:80 -N hostA
Access interface with:
http://localhost:8080, like in a web browser.
ssh -L 10554:192.168.0.100:554 -N email@example.com -g
Access the service on port 10554 on your local machine (RTSP network stream in VLC in this example):
-L forwards local TCP port to remote host.
-N Do not execute a remote command. This is useful for just forwarding ports.
-g makes the service available at all interfaces on the destination host.