Sunday, December 02, 2007

 

Persistent reverse SSH tunnel

A little while ago, I found myself with the desire to access my home machine when I'm not at home. (I was mostly looking for the ability to do things like set off an OpenSolaris "nightly" build from work so that it would be done before I was at home in front of my computer again.) I wondered if you could do something like this with ssh, and a little digging turned up the -R flag, which does exactly what I want.

While Googling on the topic, I ran across this, in which the author discusses using a cron job to make sure that the link would be re-established in the event that something terminated the process. This is one way to achieve persistence, but given that I'm running OpenSolaris at home, there's a better way to achieve the same. If I simply start the process like this:
ctrun -r 0 -t -f hwerr,core,signal ssh -R 2069:localhost:22 remote.domain.com
then Solaris will guarantee that my SSH process gets restarted whenever it dies.


Comments:
I have used autossh to be able to log to my work computer from home. It tooks about 10 minutes to set up and has work flawlessly for months.

[1] http://www.harding.motd.ca/autossh/
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?