Reverse SSH tunnelling (exit by the door and come back from the window)

Draft

What to do when you have a server behind a natted internet connection whitout public IP and you want to access it from your home or somewhere?
SSH is your best friend. So you can enable a reverse ssh tunnel that allow a connection from above the intranet.
server “S0” in the intranet —-> Router (without access) —-> (OoOo Internet oOoO) <---- router (my CISCO 803) <---- "C1" remote computer (my.example.cxm) In the server S0 I use ssh to create a tunnel that allow my C1 to connect it. On S0
ssh -R 5000:localhost:22 my.example.cxm

On Router CISCO

ip nat inside source static tcp 10.1.1.1 5000 interface Dialer 1 5000

On C1

simply launch: ssh -p 5000 localhost

and you are connected to your server in the office intranet.

What appen if the connection goes down?

we can assure that the tunnel back up again. So we must consider the idea to insert a cron job which check periodically the tunnel status.

next: example shell script