Thursday 19 October 2017

linux - How to reliably keep an SSH tunnel open?


I use an SSH tunnel from work to go around various idotic firewalls (it's ok with my boss :)). The problem is, after a while the ssh connection usually hangs, and the tunnel is broken.


If I could at least monitor the tunnel automatically, I could restart the tunnel when it hangs, but I haven't even figured a way of doing that.


Bonus points for the one who can tell me how to prevent my ssh connection from hanging, of course!



Answer



Sounds like you need autossh. This will monitor an ssh tunnel and restart it as needed. We've used it for a couple of years and it seems to work well.


autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C

More details on the -M parameter here


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...