SSH Lockout not working using pam in RHEL6
Hi,
I am trying to configure ssh lockout for a user in RHEL6.4. I Have updated below entries in /etc/pam.d/password-auth: auth required pam_tally2.so deny=3 onerr=fail unlock_time=900 account required pam_tally2.so Now if i give wrong password for a user when trying to ssh to server it disconnects after 3 attempts. But after that when i again try to login giving correct password it just logs me in. Ideally it should not as i have mentioned unlock_time=900 ie 15 minutes wait time so it should not allow me to attempt to ssh for next 15 mins. Any idea what is wrong? |
The effect that a PAM module has depends where on the stack it is placed. Can you post your full auth stack? If the authentication attempt was already allowed to succeed before pam_tally is invoked, then the pam_tally rule will have no effect.
|
Hi,
/etc/pam.d/password-auth : #%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 sufficient pam_unix.so nullok try_first_pass auth requisite pam_succeed_if.so uid >= 500 quiet auth required pam_deny.so auth required pam_tally2.so deny=3 onerr=fail unlock_time=900 account required pam_unix.so account sufficient pam_localuser.so account sufficient pam_succeed_if.so uid < 500 quiet account required pam_permit.so account required pam_tally2.so password requisite pam_cracklib.so try_first_pass retry=3 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 [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid session required pam_unix.so |
Exactly as I suspected- you put the pam_tally2.so line at the end of the auth stack AFTER the lines:
Code:
auth sufficient pam_unix.so nullok try_first_pass Note that simply changing "pam_unix" from "sufficient" to "required" will lock everyone out of your box. The reason for this is the requisite "pam_deny" call in the stack, which always refuses authentication. Because pam_unix is set as "sufficient", this call is skipped when the user types in a successful password. Another way of solving this, I think, would be to change pam_unix from "sufficient" to "required", move the pam_tally2 call directly above the pam_deny call, and change pam_tally2 from "required" to "sufficient". As a final note, do be aware of the comment in /etc/pam.d/password-auth -- if you run authconfig on your system, the content of the file do get over-written by Red Hat's ever-so-helpful utilities. |
All times are GMT -5. The time now is 06:15 AM. |