How to set the ssh connection timeout (ssh timeout)
This article describes how to set the ssh connection timeout in linux to avoid force exit. For more information, see.
I have introduced a lot about how to modify the ssh connection timeout.
For example:
This can reduce the time-out waiting for ssh connections:
Method: ssh-o ConnectTimeout = 3 192.168.0.10
Or modify the UseDNS option in the sshd_config file to UseDNS no.
Smart readers will surely find that the above modification is actually to reduce the ssh connection time, that is, to make the ssh response time faster.
Refer to the previous article: How to Solve ssh connection timeout (usedns option of ssh.
Next, set the ssh timeout.
Modify the. bash_profile file in the root directory, and add
Export TMOUT = 1000000 (in seconds)
Then run:
Source. bash_profile
Add the following to/etc/ssh/sshd_config:
ClientAliveInterval = 60
Every minute, sshd sends a greeting to the ssh client to check whether it exists and disconnects when it is not stored.
Note: After the configuration is complete, You need to exit the ssh remote connection and log on again to make the setting take effect. Because it needs to be read again./bash_profile.
For convenience, the settings are written as the following script:
Echo export TMOUT = 1000000>/root /. bash_profilecat/root /. bash_profilesource. bash_profilecp/etc/ssh/sshd_config/etc/ssh/sshd_config_bakecho ClientAliveInterval = 60>/etc/ssh/sshd_configservice sshd restartcat/etc/ssh/sshd_configservice sshartcat restartex
Summary:
In ClientAliveInterval (/etc/ssh/sshd_config), Environment Variable TMOUT (set in/etc/profile or. bash_profile), and putty's "Seconds between keepalives ",
Detection: Only TMOUT can control the time-out of ssh connections during idle time. The time for automatic disconnection is measured in seconds ".
After TMOUT is set (not 0), the other two variables do not work.
In addition, after setting the ssh logon timeout time, remember to log out and log on again or restart the system for the configuration to take effect.