Prevent SSH connection from timing out in Terminal
If you’re constantly connected to multiple servers via SSH and perform work on them throughout the day, dealing with timeouts can be cumbersome. Here’s how you can keep the connection alive.
config file in your home’s
$ vi ~/.ssh/config
Add the following by pressing the letter
i, typing in the text below, and pressing
ESC followed by
Every 60 seconds a packet will be sent to keep the connection alive.
Lastly, modify the
config file so that it’s read-only to you:
$ chmod 600 ~/.ssh/config
From here on out, no more timeouts.
Featured image by Samuel Sosina.