How to set the ssh connection timeout (ssh timeout)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.