Skip to content

Instantly share code, notes, and snippets.

@QuiteZeal
Last active April 22, 2020 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QuiteZeal/f566f54e87c8d9754385f3674d1e7109 to your computer and use it in GitHub Desktop.
Save QuiteZeal/f566f54e87c8d9754385f3674d1e7109 to your computer and use it in GitHub Desktop.
Keep ssh connection alive.

Keep ssh connection alive

Here is the solution to keep the terminal ssh status alive

If you don't know where the file you should change, you can:

$ find / -name "ssh_config" it will tell where is it, such as /etc/ssh/sshd_config

change the default config

$ sudo vim /etc/ssh/sshd_config and find

#ClientAliveInterval 0
#ClientAliveCountMax 3

at centos 8, it at line 122(about at the end).

ClientAliveInterval means timeout to reactive connect, if its value equals to 0, it disables, so you can set 15, which means 15 seconds. ClientAliveCountMax is the reactive times, you can set it to 10.

such as:

ClientAliveInterval 15
ClientAliveCountMax 10

which means the terminal will reactive connection ever 15s, if the host doesn't respond, it will try 10 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment