Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to limit the number of SSH logins in Centos

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Centos how to limit the number of SSH login, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

The first method: verified.

1.ssh timeout setting

# cd / etc/profile.d/ # create two blank files autologout.csh and autologout.sh to save the TMOUT configuration

# touch autologout.csh

# touch autologout.sh

# vi autologout.sh # Editing autologout.sh

# auto out in 5 minutes

TMOUT=300 # timeout in s

Readonly TMOUT # set the TMOUT variable read-only

Export TMOUT # set environment TMOUT

# vi autologout.csh # Editing autologout.csh

Set-r autologout 2

# chmod + x autologout.* # executable permissions, in fact, just give Ubunx.

Disconnect Client, log in to the terminal again for 5 minutes without using ssh will automatically disconnect.

2. Limit the number of ssh authentication:

/ etc/ssh/sshd_config

MaxAuthTries=3 this is only more than 3 validation errors disconnecting.

The second method: (there are still problems in the experiment)

Principle: realized through the pam authentication of the system.

1. Backup / etc/pam.d/system_auth file, change:

#% PAM-1.0

# This file is auto-generated.

# User changes will be destroyed the next time authconfig is run.

Auth required pam_env.so

Auth required pam_unix.so nullok try_first_pass changed the original sufficient to required

# auth requisite pam_succeed_if.so uid > = 500quiet comment out this line

Add one line to auth required pam_tally.so deny=3unlock_time=300 and log in after 5 minutes after 3 failures.

# auth required pam_deny.so comment out this line

Account required pam_unix.so

Account sufficient pam_succeed_if.so uid

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report