Linux has a pam_tally2.so PAM module to limit the number of logon failures. if the number of logon failures reaches the set threshold, the user is locked. Compile PAM configuration file # vim/etc/pam. d/login # % PAM-1.0authrequiredpam_tally2.sodeny = 3lock_time = 300even_deny_rootr
Linux has a pam_tally2.so PAM module to limit the number of logon failures. if the number of logon failures reaches the set threshold, the user is locked.
Compile the PAM configuration file
# Vim/etc/pam. d/login
#%PAM-1.0
auth required pam_tally2.so deny=3lock_time=300 even_deny_root root_unlock_time=10
auth [user_unknown=ignoresuccess=okignoreignore=ignore default=bad] pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session optional pam_keyinit.so force revoke
session required pam_loginuid.so
session include system-auth
session optional pam_console.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open
Parameter description
Even_deny_root also limits root users;
Deny sets the maximum number of consecutive error logins for common and root users. if the maximum number of logon attempts is exceeded, the user is locked.
Unlock_time specifies the time after which a common user can unlock the lock, in seconds;
Root_unlock_time specifies the time after the root user locks the unlock, in seconds;
The pam_tally2 module is used here. if pam_tally2 is not supported, the pam_tally module can be used. In addition, different pam versions may have different settings. for specific usage instructions, refer to the usage rules of relevant modules.
Under the # % PAM-1.0, that is, the second line, add content, must be written in front, if written in the back, although the user is locked, but as long as the user enter the correct password, you can still log on!
The final result is as follows: