I am trying to establish a reverse SSH tunnel from my home network. I've got it so that autossh connects successfully once (and only once) per reboot. I'm forwarding remote ports to my local machine so that I can connect when away from home. I'm on satellite internet and am behind a double-NAT firewall, so connecting directly to my home network is a non-starter.
It seems like the ports on the remote machine are left in an open state when the ssh connection drops out the first time. Any subsequent attempts to reconnect fail because the ports are already in use. I can't get things started again until I've rebooted the server, which is less than ideal.
Haven't had any luck with Google or forum searches so am hoping someone here might point me in the right direction.
I've configured the server and local machine following the guidance here:
http://linuxaria.com/howto/permanent-ssh-tunnels-with-autossh
My connect script is excerpted below and included in /etc/rc.local:
su -s /bin/sh autossh -c 'autossh -M 20000 -f -i /home/autossh/.ssh/id_rsa -N -R 99999:localhost:22 autossh@remotehost.com'
Cheers and thanks in advance for any help!
Corey