How to make your SSH Terminal shell sessions last longer on macOS

If you find that your SSH shell sessions to remote computers are timing out too quickly with the error “Write failed: Broken pipe”, you can make a simple configuration to keep these sessions going as long as you have your terminal shell window running: 

Move into your SSH settings folder

cd ~/.ssh

Create a local SSH config file

nano config

Add in a session variable

ServerAliveInterval 60

Write out and save the file.

So the next time you initiate a SSH session with a remote computer, after 60 seconds of inactivity a ‘no-op’ (no operation) message is sent to keep the session alive and it just keeps going and going.