May 15, 2025
How to Keep SSH Connections Alive on Mac

How to Keep SSH Connections Alive on Mac

Posted December 9, 2021 at 5:45am by iClarified · 26198 views
These are instructions on how to prevent timeout and keep SSH connections alive on Mac.

Step One
Launch Terminal from your Applications > Utilities folder.
How to Keep SSH Connections Alive on MacHow to Keep SSH Connections Alive on Mac

Step Two
Execute the following command into the Terminal window...

sudo nano ~/.ssh/config
How to Keep SSH Connections Alive on MacHow to Keep SSH Connections Alive on Mac

Enter your administrative user password when prompted.
How to Keep SSH Connections Alive on MacHow to Keep SSH Connections Alive on Mac

Step Three
Add the following line to your ssh config file.

ServerAliveInterval 100


Step Four
Press Control+x to exit, then press Y when prompted to save changes.


Step Six
Press Return to confirm the filename and exit.




New SSH connections should now stay open indefinitely. You can shorten or lengthen the interval as required by your server.