Thursday, December 06, 2012

SSH Tunnel with auto reconnect

If you want to make your SSH Tunnel automatic reconnect when it is disconnected, you can use autossh.
This is an examples how to configure autossh to make tunnel on port 10088 in local server and on port 10087 in yourserver.com and only accessible from yourserver.com

Put these codes in the rc.local :

AUTOSSH_POLL=600
AUTOSSH_GATETIME=30
export AUTOSSH_POLL AUTOSSH_GATETIME
autossh -2 -M 20000 -fN username@yourserver.com -R 10087:localhost:10088 -N