How to auto disconnect inactive users after a period of time in Linux

0
114

If there are many users who access to your system, it’s dangerous and resource-consuming when users keep their ssh connection for a long time. In this post, I would like to show you some methods to auto-disconnect ssh session after a period of time.

Method 1: Using .bashrc

In the /home/user/.bashrc or /home/user/.bash_profile, add following line:

Method 2: Using sshd_config
In /etc/ssh/sshd_config, add:

Then, you need to restart the ssd service to apply changes.

Method 3: Using script in /etc/profile.d/
In /etc/profile.d/, create a autodisconnect.sh with the following contents:

Note that, you need to make the script executable, the script will be run at OS startup to enable disconnecting.

BÌNH LUẬN

Vui lòng nhập bình luận của bạn
Vui lòng nhập tên của bạn ở đây