SSH Connection drops offline after a few minutes of no activity

Posted October 15, 2017 5.1k views
NginxUbuntu 16.04

Whenever I’m connected to my droplet through SSH and stop using it for a few minutes, it drops offline and I get the message “broken pipe”. It doesn’t seem to be associated with any sort of time limit, but more to do with how much time there is between activity. For example, I am often going between the terminal and the #Laravel chat room for help, but if I’m gone for too long it’s disconnected when I get back. Is there anything I can do to avoid this?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

You can set keep alive in the command line:
ssh -o ServerAliveInterval=30 <your-server>

or set it in the ssh server config:
ClientAliveInterval 60
ClientAliveCountMax 2

Thank you. I just tried your idea and it still disconnects. I restarted nginx but it didn’t seem to make a difference :(