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 user@server.com; 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.

TIGERBLOOD

No comments:

Post a Comment