Does an expired password block SSH public-key login on openSUSE Leap?
0 reputation · 05 Jan 2025, 01:36 UTC
0 reputation · 05 Jan 2025, 01:36 UTC
On openSUSE Leap 15.x, the shadow suite stores password aging in /etc/shadow, managed through chage or YaST. Two mechanisms are easy to conflate: password expiry past the maximum age, which normally forces an immediate change at the next login via PAM, and a hard account expiry date, which blocks login outright. A third state, the inactivity lock that disables the password after the post-expiry grace period, adds further ambiguity.
The unresolved case is key-based SSH. With public-key authentication no password is ever presented, so it is unclear whether an expired password blocks the session, allows it silently, or triggers a forced-change flow that may not even be possible without password authentication. Behavior reportedly depends on sshd's UsePAM setting and the account checks in the PAM stack, and defaults may differ between Leap and Tumbleweed. Accounts backed by SSSD or LDAP bypass local shadow aging entirely, moving enforcement to the identity backend.
Assuming a default Leap 15.x install with a PAM-enabled sshd configuration:
On a default openSUSE Leap 15.x installation, an expired password (i.e., the password has reached its maximum age and requires a change on the next password‑based login) does not block SSH public‑key authentication. The session will succeed as long as the key is valid and the account is otherwise enabled.
UsePAM yes by default, so the PAM account phase (pam_unix in /etc/pam.d/sshd) is invoked for every login, including public‑key sessions.pam_unix module checks the shadow file’s maximum age field (shadow field #5). If the password is expired, the module only forces a password change when the user supplies a password; it does not deny the session outright.chage -E date, shadow field #8) is enforced by the same PAM account module and will cause a denial of login regardless of authentication method.chage -I) behaves like password expiry: it only affects password authentication and does not block key‑based logins./etc/shadow aging is bypassed; expiry is enforced by the directory backend (e.g., LDAP password‑policy overlay or AD accountExpires).Check that SSH is using PAM:
sshd -T | grep -i usepam
# Expected output: usepam yes
Create a test user and set a password that is already expired:
sudo useradd -m testuser
sudo passwd testuser
# set password to a known value
sudo chage -d 0 testuser # force expiry
Generate or copy an SSH key for testuser and add it to ~testuser/.ssh/authorized_keys.
Attempt a key‑based login from another host:
ssh -i ~/.ssh/id_rsa testuser@host
# You should be logged in without a password prompt.
Now set a hard account expiry in the past:
sudo chage -E 1 testuser # 1 Jan 1970
Retry the key login:
ssh -i ~/.ssh/id_rsa testuser@host
# The connection should be refused; check logs:
journalctl -u sshd | grep testuser
chage -E or usermod -L to lock the account; this will block all authentication methods.PermitEmptyPasswords no in /etc/ssh/sshd_config to prevent login when the password field is empty.Does your system use a custom PAM stack that disables pam_unix during the account phase? If so, key‑based logins may behave differently. Check /etc/pam.d/sshd for any overrides.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.