Pages

Wednesday, January 28, 2009

Ssh stable reverse tunnel

Many servers are being accessed using tunnels and we are tired of recreating the tunnel again & again. Here is script which can sure the availability of tunnel.
The solution to use ssh command without using the console(tty) is to add -t -t option. Option can be used for remote/local tunnels also.
Eg : ssh -t -t -R 2222:localhost:22 username@

This will create a pseudo terminal which will login to remote server. So, actual terminal is not engaged by ssh proc, which makes the tunnel more stable & consistent. To add on further check, we can check if ssh proc is running & create new ssh tunnel using shell script with a cron job at hourly interval. Shell script can be changed to reset tunnel every hour using kill $PID & recreate tunnel to insure availability.
For further details check man pages. Such tunnels can be configured to allow remote login to office machine. Feel free to ask if have any query. Sample tunnel script attached with mail.

Further suggestion are welcome !

No comments:

Post a Comment

Comments welcome :