Accounts locked out — faillock, pam_tally and expired passwords
Authentication is being refused by PAM before the password is even considered — a lock, an expiry, or a shell that prevents login.
What you see
A correct password is rejected. The message may mention a lock, or may be a generic authentication failure with the real reason only in the log.
What is actually wrong
Failed attempt counters that have reached their limit, a password or account expiry date that has passed, or an account whose shell has been set to nologin.
Codes and articles
Fixes (3)
Read what PAM actually rejected
Always start here — the reason is logged and guessing wastes time.
Read the authentication log for the exact refusal.
sudo journalctl -t sshd -t sudo -t login --since '30 min ago' --no-pager | tail -40sudo tail -60 /var/log/auth.log 2>/dev/null || sudo tail -60 /var/log/secure
Check the account's state directly.
sudo passwd -S usernamesudo chage -l usernamegetent passwd username
passwd -S shows L for locked, P for a usable password and NP for none. chage -l shows every expiry date. Between them they answer this in ten seconds without touching a configuration file.
Check the shell — an account with /usr/sbin/nologin or /bin/false authenticates and is immediately disconnected, which looks like a rejected password.
getent passwd username | cut -d: -f7Check the account is not simply absent from a required group or an AllowUsers list in sshd.
Clear the failed attempt counter
Too many failed attempts.
See the counter and when it will clear on its own.
sudo faillock --user usernamesudo pam_tally2 --user username 2>/dev/null
Reset it.
sudo faillock --user username --resetFind out what caused the failures before assuming it was the user. A saved credential in a phone or a scheduled task retrying an old password will lock the account again within minutes.
sudo journalctl -t sshd --since '2 hours ago' | grep -i 'failed password' | awk '{print $(NF-3)}' | sort | uniq -c | sort -rn | headRepeated lockouts are almost never the person typing. The source address in the log names the device or service that is still trying the old password, and that is the thing to fix.
Review the policy if lockouts are frequent — the defaults in /etc/security/faillock.conf are often stricter than intended.
grep -vE '^\s*#|^\s*$' /etc/security/faillock.confConsider whether the account should be exposed to the internet at all. Key-only SSH removes password lockouts entirely.
sudo faillock --user usernameDeal with an expired password or account
An expiry date has passed.
Read all the dates at once.
sudo chage -l usernameAn expired password can be changed at login; an expired account cannot log in at all. They are separate fields and the distinction matters.
Extend or clear the account expiry.
sudo chage -E -1 usernameForce a password change at next login rather than setting a password on the user's behalf.
sudo chage -d 0 usernameSetting a password for someone means you know it. Expiring it forces them to set their own at the next login, which keeps the credential theirs.
Unlock the account if it was locked.
sudo usermod -U usernamesudo passwd -S username
Check the account is not simply disabled by an exclamation mark in the shadow file, which usermod -U clears.
sudo chage -l username; sudo passwd -S usernameWhere this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.