A solution that is disconnected for a long time when SSH is connected to Linux (enhanced version)

Source: Internet
Author: User

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)

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.