Windows
xshell或securecrt会自动保持连接,putty设置如下:
In your session properties, go to Connection and under Sending of null packets to keep session active, set Seconds between keepalives (0 to turn off) to e.g. 300 (5 minutes).
Linux
vim ~/.ssh/config
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
or /etc/ssh/ssh_config
参考:https://patrickmn.com/aside/how-to-keep-alive-ssh-sessions/