ssh remote port forwarding
$ ssh -R 9000:localhost:3000 user@example.com
For Windows
plink.exe -ssh -l user -pw <PWD> -R 9000:localhost:3000 example.com -P 22 -batch
The syntax here is very similar to local port forwarding, with a single change of -L
for -R
. But as with local port forwarding, the syntax remains the same.
First you need to specify the port on which th remote server will listen, which in this case is 9000
, and next follows localhost
for your local machine, and the local port, which in this case is 3000
.
There is one more thing you need to do to enable this. SSH doesn’t by default allow remote hosts
to forwarded ports. To enable this open /etc/ssh/sshd_config
and add the following line somewhere in that config file.
GatewayPorts yes
Make sure you add it only once!
$ sudo vim /etc/ssh/sshd_config
And restart SSH
$ sudo service ssh restart