ssh modifies the way timeout automatically logs out

  • 2020-05-17 07:36:24
  • OfStack

preface

As we all know, when we log in to another server remotely via ssh, if we don't do anything for a long time, the server will automatically log out and tell you timed out waiting for input: auto-logout. If session is not maintained via tmux, then we need to modify the logout time of the server to prevent automatic logout.

Modify the steps

First of all, let's take a look at 1. What is the automatic logout time on the server?


$ echo $TMOUT

If nothing comes out, does that mean your server won't log out automatically

If there is output in the previous step, such as 600, then your server's automatic logout time is 600s, or 10 minutes. Usually this value is defined in /etc/profile . /etc/bashrc or ~/.bash_profile,~/.bashrc And so on these system environment configuration files.

Note that the values defined in these files in the home directory override those defined in /etc in the following files, for example ~/.bash_profile的TMOUT The variable will override /etc/profile In the TMOUT variable

Below, we modify the value of TMOUT as required:

TMOUT=600 # That means you'll log out automatically after 10 minutes TMOUT= # Means close automatic logout

It is important to note that there are no Spaces around the equals sign

Once we've done that, let's say we've done that ~/.bash_profile File. If we want the changes to this configuration file to take effect immediately, we need to execute the following code:


$ source ~/.bash_profile

Or log out and then log in.

conclusion

The above is all about the modification of ssh overtime logout time, I hope the content of this article can bring you a definite help in your study or work, if you have any questions, you can leave a message to communicate.


Related articles: