tunneling through reverse ssh to local system

By | 14th October 2015

I always wondered how do people connect to systems inside a LAN, this is one of the methods.

LocalSystem: Laptop, Desktop or any system to which you want others to connect
RemoteSystem: This will act as an anchor point or a route through which we connect.

On the RemoteSystem open the file /etc/ssh/sshd_config and add this line to end of the file.
GatewayPorts=clientspecified
Restart ssh
service ssh restart

Now for the system to which you want others to connect give this command. Run the command on LocalSystem
ssh -R 0.0.0.0:[port]:localhost:22 [user]@[RemoteSystem]

Everyone can connect to LocalSystem by giving the following command
ssh -p [port] [LocalSystemUser]@[RemoteSystem]

To check if the port is open for every one i.e 0.0.0.0
netstat -nlpt |grep [port]