A little bg story: I’m writing a rails app, which is hosted inside the corporate network, and no incoming traffic is permitted. I need to expose the internal port 3000 to the public.
Short answer: SSH forwarding.
$ ssh -R 3000:localhost:3000 [email protected]
For some reason, the forwarding only works when I set both the local and remote port as 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.
Make sure you add it only once!
$ sudo vim /etc/ssh/sshd_config
And restart SSH
$ sudo service ssh restart