CentOS uses PAM to lock users who fail to log on multiple times

Source: Internet
Author: User
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

 
  1. #%PAM-1.0

  2. auth      required  pam_tally2.so   deny=3lock_time=300 even_deny_root root_unlock_time=10

  3. auth [user_unknown=ignoresuccess=okignoreignore=ignore default=bad] pam_securetty.so

  4. auth       include      system-auth

  5. account    required     pam_nologin.so

  6. account    include      system-auth

  7. password   include      system-auth

  8. # pam_selinux.so close should be the first session rule

  9. session    required     pam_selinux.so close

  10. session    optional     pam_keyinit.so force revoke

  11. session    required     pam_loginuid.so

  12. session    include      system-auth

  13. session    optional     pam_console.so

  14. # pam_selinux.so open should only be followed by sessions to be executed in the user context

  15. session    required     pam_selinux.so open

Parameter description

 
  1. Even_deny_root also limits root users;

  2. 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.

  3. Unlock_time specifies the time after which a common user can unlock the lock, in seconds;

  4. Root_unlock_time specifies the time after the root user locks the unlock, in seconds;

  5. 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:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.