If you use SSH to connect to remote Linux servers you8217ll notice that if you keep your SSH session inactive for some time and then try to use it again the SSH session disconnects with an error message like this.
On some systems it will display 8216Write failed Broken pipe8217 or 8216Connection closed by remote host8217.
Let8217s see what causes this error and how to go about keeping your SSH connection alive.
As you may have guessed the SSH connection is closed because of inactivity. There is no set value but it usually around 5 minutes or so.
What you can do to avoid the SSH session disconnection is to send an 8216alive message8217 either from the server to client ClientAliveInterval or from client to server ServerAliveInterval at certain time interval.
This way you keep the SSH session alive because there is a communication between the client and server and the server understands that client is still there.