赞
踩
Configure /etc/pam.d/system-auth
and /etc/pam.d/password-auth
as below:
Case 1:
- auth required pam_env.so
- auth required pam_faillock.so preauth silent audit deny=3 unlock_time=600
- auth sufficient pam_unix.so nullok try_first_pass
- auth [default=die] pam_faillock.so authfail audit deny=3 unlock_time=600
- auth requisite pam_succeed_if.so uid >= 500 quiet
- auth required pam_deny.so
-
- account required pam_faillock.so
- account required pam_unix.so
- account sufficient pam_localuser.so
- account sufficient pam_succeed_if.so uid < 500 quiet
- account required pam_permit.so
-
- ..snip..
Case 2:
- auth required pam_env.so
- auth [success=1 default=ignore] pam_unix.so nullok try_first_pass
- auth [default=die] pam_faillock.so authfail audit deny=3 unlock_time=600
- auth sufficient pam_faillock.so authsucc audit deny=3 unlock_time=600
- auth requisite pam_succeed_if.so uid >= 500 quiet
- auth required pam_deny.so
-
- account required pam_unix.so
- account sufficient pam_localuser.so
- account sufficient pam_succeed_if.so uid < 500 quiet
- account required pam_permit.so
-
- ..snip..
The above configuration file would lock out users after 3 unsuccessful login attempts and unlock them after 10 minutes.
auth required pam_faillock.so
line should be added in both /etc/pam.d/system-auth
and /etc/pam.d/password-auth
as follows :auth required pam_faillock.so preauth silent audit deny=3 even_deny_root unlock_time=1200 root_unlock_time=600
pam_faillock
in both /etc/pam.d/system-auth
and /etc/pam.d/password-auth
and replace user1, user2 with the actual usernames.auth [success=1 default=ignore] pam_succeed_if.so user in user1:user2:user3
For more information of parameters in
pam_faillock.so
refer man page ofpam_faillock
.
# faillock --user <username>
And for resetting authentication failure records:
# faillock --user <username> --reset
pam_faillock.so
is not working as expected, the following changes may have to be made to SSHD's configuration:- # vi /etc/ssh/sshd_config
- ChallengeResponseAuthentication yes
- PasswordAuthentication no
Then restart the sshd
service in order for these configuration changes to take effect:
# systemctl restart sshd
Note: Sequence of the lines in the files are important and any change in sequence would end up locking all users including root user when you are using even_deny_root
option.
References:
Where is faillog command for Red Hat Enterprise Linux 6 ?
Note: pam_faillock module support temporary locking of user accounts in the event of multiple failed
authentication attempts. This new module improves functionality over the existing pam_tally2 module, as it also
allows temporary locking when the authentication attempts are done over a screensaver.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。