How do I prevent my SSH connection from dropping?

Linode Staff

When my SSH connection is idle for a relatively short time, it drops. The error I get is:

end disconnect: Broken pipe

How can I prevent this from happening?

3 Replies

If the connection is dropping when your local machine goes to sleep, you may need to adjust a setting in your OS in order to keep network connections active while in sleep mode. The exact setting, and whether or not you can do this, will depend on the OS you're using.

That said, I recommend first trying to increase the connection timeout time in your Linode's /etc/ssh/sshd_config file:

ClientAliveInterval 120
ClientAliveCountMax 720

ClientAliveInternal tells sshd to check that a connection a connected client still exists every 120 seconds. ClientAliveCountMax tells 'sshd' only to drop a connection after 720 failed checks (which, in this case, is 24 hours). With these settings, your SSH server will timeout connections only after 24 hours. Make sure to restart sshd to apply the changes:

sudo systemctl restart ssh

and or running ssh directly from web admin instead of standard ssh client command

nohup long-running-process &

if make -j24 is a command

nohup make -j24

to detach from current running tty with background / foreground

nohup make -j24 &

to resume
fg %1


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct