Thursday, March 10, 2011

Auto restart your SSH connection

Here is a simple bash one liner that will automatically restart your ssh connection if it drops.

while true; do ssh; sleep 15; done

It's simple, this will run until killed. The first thing the loop does is start up ssh and since it cant continue until ssh exists, its effectively a method to always restart the connection (without duplicating the process)

This assumes you have key auth setup and ready to go.


No comments:

Post a Comment