Showing posts with label autossh on boot. Show all posts
Showing posts with label autossh on boot. Show all posts

22 December 2012

299. Briefly: Start autossh at boot on debian testing/wheezy

I have one of my work computers set up to create a reverse tunnel to my WRT54G router at home, so that by login in to my router at home and then connecting to localhost:19996 I can access my work network from home. The problem is that if I reboot my work computer remotely I need to make sure that it tries to recreate the reverse ssh tunnel.

The way to do that is by editing /etc/rc.local and putting the following in it:
su lindqvist -c 'autossh -N -f -M 29001 -R 19996:localhost:22 remoteuser@my.router.com' &

Make sure you put it before the line that says
exit 0

linqdvist is the user at on my work computer I want to be running the autossh, 19996 is the port I'll connect to on my home router to gain access to the ssh port on my work computer. Since I'm using WRT54G with Tomato the remoteuser is root, and I got my dns (remote hostname) as shown in this post: http://verahill.blogspot.com.au/2012/02/tomato-router-and-free-dns.html
It's that simple.