How to share a reverse SSH tunnel on a network

reverse-tunnelssh

I have a remote computer on a 3G PPP connection.
I can't connect to this computer via the Internet as I believe the PPP IP pool uses NAT to connect to the Internet (I get given a 10.x.x.x address when I connect)

So I get the remote computer to create a SSH connection to a server on the Internet.
I can then tunnel down this connection from the server and get a shell on the remote computer. Great.

I want to be able to access the Web interface of a camera on the remote network.
So I create a second SSH tunnel that redirects traffic to the address of the camera, ie:
ssh -R 9000::

From my Internet host this works, I get the web page:
wget 127.0.0.1:9000
Great

Now I need this to work from my client PC so:

Client PC –> Internet server –tunnel–> Remote computer –> IP camera

So essentially I need to make my reverse SSH tunnel available over the network.

I assumed if I just used iptables to forward incoming traffic on a certain port on my Internet server to 127.0.0.1:9000 that would work but I haven't been able to make it work after hours of playing with iptables, NAT etc.

Should this work?

Best Answer

I think you need -o GatewayPorts=yes to allow other hosts than local to use your tunnel. From the man-page:

Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be “yes” or “no”. The default is “no”.

Related Question