0

When I try to login 3 times with the wrong password (locally), instead of seeing user locked out message:

su - myuser
Account locked due to 3 failed logins

I see this:

[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Permission denied
[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Permission denied
[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Authentication failure
[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Authentication failure
[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Authentication failure
[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Authentication failure
[myuser@ip-10-10-2-53 ~]$ su - myuser
Password: 
su: Authentication failure
[myuser@ip-10-10-2-53 ~]$ sudo faillock 
myuser:
When                Type  Source                                           Valid
2018-03-23 21:26:26 TTY   pts/1                                                V
2018-03-23 20:54:01 RHOST 192.168.8.67                                         I
2018-03-23 20:54:05 RHOST 192.168.8.67                                         I
2018-03-23 20:58:39 RHOST 192.168.8.67                                         I
2018-03-23 20:58:41 RHOST 192.168.8.67                                         I
2018-03-23 21:24:50 TTY   pts/1                                                I
2018-03-23 21:24:56 TTY   pts/1                                                I
2018-03-23 21:26:55 TTY   pts/1                                                V
2018-03-23 21:26:59 TTY   pts/1                                                V
root:
When                Type  Source                                           Valid

My /etc/pam.d/password-auth and /etc/pam.d/system-auth files (they both exactly the same)

#%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_faildelay.so delay=2000000
auth        required      pam_faillock.so preauth silent audit deny=3 even_deny_root unlock_time=60
auth        sufficient    pam_unix.so nullok try_first_pass
auth        [default=die] pam_faillock.so authfail audit deny=3 even_deny_root unlock_time=60
auth        requisite     pam_succeed_if.so uid >= 1000 quiet_success
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 < 1000 quiet
account     required      pam_permit.so

password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
-session     optional      pam_systemd.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so
alexfvolk
  • 164
  • 1
  • 9

1 Answers1

2

in auth section is silent for pam_failock which prevents to display message about lockout (because this can help to identify existing accounts). If you want to display message, you need to use

auth     requisite      pam_faillock.so preauth audit deny=3 even_deny_root unlock_time=60

which also prevent password promt for locked accounts

Longer explanation is in man page https://linux.die.net/man/8/pam_faillock

Quantim
  • 1,269
  • 11
  • 13
  • But why does it lockout message never show for ssh logins. It works for local and shows lockout message. But when I do ssh, it locks me out because I cannot get in after 3 attempts with correct password, but never shows me the lockout message. – alexfvolk Mar 26 '18 at 18:31
  • @Quantim It *isn't* showing the lockout message. It's showing a generic authentication error. While that message is different than the permissions error originally displayed by su, is still a generic error. `silent` is working exactly as intended for the remote connections, and offering no indication that the PAM module is blocking the authentication attempt (regardless of password validity). – Andrew B Mar 28 '18 at 20:15