Automatically log out of Linux Shell with TMOUT with just a few simple steps with AZDIGI.
Surely in the process of using VPS, you are or have been many times SSHing into VPS but not performing administrative operations or running any commands. For some reason, you forgot to exit the command line window or have an unexpected job to go somewhere without time to exit (this case can be called an “idle session”).
And of course, this can bring some security risks, especially when you are logged in as root and many people around you can simply sabotage your VPS or insert Malware into your VPS.
Therefore, there must be a certain solution to be able to handle the problem when encountering the above cases. And one idea to deal with this is to configure it so that the system will automatically log out in case an idle session occurs. And to do that, we will use a variable named TMOUT. And in detail on how to do it, please see below.
II. Implementation guide
To configure TMOUT, you can do the following 2 steps.
Step 1: SSH into your server
First, you need to SSH into your VPS as root, if you don’t know how to SSH, you can see the instructions below:
Step 2: Enable TMOUT
To enable TMOUT for all users in the system, you need to set the above variable in the profile file. You open the file with the command below:
Then you add the TMOUT variable as follows:
The number 60 here is the number of seconds that the system will automatically log out (you can replace the number of seconds you want), meaning that after 60 seconds, if you do not have any operations on the VPS, the system will automatically log out.
In this configuration section, if you only need to configure a specific user, you can configure them in their ~/.profile file. If you want to disable TMOUT, just delete the TMOUT variable or set the number of seconds to 0.
After editing, you need to run the command below to update the configuration.
After the configuration is complete, please try to check if TMOUT is working by not doing anything on the VPS according to the time interval you configured. Like here, after 60 seconds of not doing anything, the system was automatically logged out.
Thus, in this article, AZDIGI has shown you how to automatically log out of Linux Shell with TMOUT on a Linux server, complete with just a few simple commands. This setup will help you in some cases of negligence in using and administering VPS in order to protect VPS against bad guys who intend to destroy VPS. Wishing you success!
If you need assistance, you can contact support in the ways below:
- Hotline 247: 028 730 24768 (Ext 0)
- Ticket/Email: You use the email to register for the service and send it directly to: email@example.com