1. First Attempt failed
Modify the/etc/ssh/sshd_config file,
Found it
Clientaliveinterval 0
Clientalivecountmax 3
and remove the annotation symbol ("#"),
Change the corresponding 0 of the clientaliveinterval to 60,
CLIENTALIVEINTERVAL Specifies the time interval for server-side request messages to clients, which is 0 by default and not sent.
Clientaliveinterval 60 indicates that it is sent once per minute, and then the client responds so that it remains long connected.
Clientalivecountmax, use the default value of 3.
Clientalivecountmax indicates that the client does not respond to a certain number of times after the server makes a request and disconnects automatically.
Normally, the client does not respond.
To re-start the sshd service:
Service sshd Restart
It's still not long before you break the window
2. Second attempt to succeed
In order to enhance the security of the Linux system, we need to automatically disconnect after the user input is idle for a period of time, this operation can be implemented by setting the Tmout value. Add the following fields to/etc/profile (valid for all users).
Export tmout=900 # Set User no action on field disconnect terminal within 900 seconds
ReadOnly Tmout # Set the value to ReadOnly prevent users from changing
Note: After setting the readonly in the current shell can not be canceled, you need to set the/etc/profile readonly line annotation or directly delete, logout and re-login.
$ Export tmout=900
$ readonly Tmout
$ unset tmout
-bash:unset:tmout:cannot unset:readonly Variable
A solution that is disconnected for a long time when SSH is connected to Linux (enhanced version)