Last Updated: February 25, 2016
·
594
· victorbrca

How to Make SSH Tunnel Available on the Network

See this post on my blog

Let's say you created a reverse tunnel to a remote computer/server and you want other computers on the same network to be able to connect to that tunnel. Sometimes this will work out of the box, but other times it requires additional changes.

On this example, I have created a reverse tunnel on port 8080 to my desktop compute with the command below:

ssh -R 8080:127.0.0.1:8080 [user]@desktop

However other computers on the same network cannot connect to it. When I check my desktop, I see that it's listening on that port, however it does not seem to be open (0.0.0.0)

# netstat -an | grep 8080
tcp        0      0 127.0.0.1:8080              0.0.0.0:*                   LISTEN

1- Check your /etc/ssh/sshd_config and make sure you have GatewayPorts uncommented and enabled:

GatewayPorts yes

Test your connection and see if that works. If it didn't, create the SSH tunnel again with one of the following options:

ssh -R \*:8080:127.0.0.1:8080 [user]@desktop

or

ssh -R 0.0.0.0:8080:127.0.0.1:8080 [user]@desktop