Skip to content

How to prevent SSH form automatically disconnecting

Method 1

Let server send heartbeat to client.

sudo vi /etc/ssh/sshd_config, add following codes:

ClientAliveInterval 30
ClientAliveCountMax 6

ClientAliveInterval means how ofen server sending heartbeat to client.
ClientAliveInterval means how many times no response to believe tcp is disconnected.

Method 2

Let client send heartbeat to server.

On Windows:

Set it in your ssh client (Putty、MobaXterm…)

Putty
MobaXterm

On Linux:

sudo vim /etc/ssh/ssh_config, add following codes:

ServerAliveInterval 30
ServerAliveCountMax 6
Leave a Reply