Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
Step by step
- Strength — pwquality checks new passwords:
| Setting | Means |
|---|---|
minlen = 14 | At least 14 characters. |
minclass = 3 | At least 3 of: lower, upper, digit, other. |
dictcheck = 1 | Reject dictionary words. |
usercheck = 1 | Reject passwords with the user name. |
enforce_for_root | Also for root (otherwise root gets only a warning). |
- Age for existing users with
chage:
chage -M 90 -m 1 -W 14 alice
chage -l alice
Maximum number of days between password change : 90
Number of days of warning before password expires : 14-M max days, -m min days (stops changing back at once), -W warning days. chage -d 0 alice forces a change at the next login.
- Defaults for new users in
/etc/login.defs(only users created after the change):
PASS_MAX_DAYS 90
PASS_MIN_DAYS 1
PASS_WARN_AGE 14- Lockout after failed logins (faillock):
deny = 5
unlock_time = 900
fail_interval = 900authselect enable-feature with-faillock
faillock --user alice
faillock --user alice --reset5 failures in 15 minutes lock the account for 15 minutes; --reset unlocks it at once.
- Modern advice to discuss with the auditor: current NIST guidance prefers long passwords/passphrases, a check against leaked passwords, MFA, and no forced regular expiry (only change after a suspected leak). Many company policies still ask for expiry — follow your policy, but long + MFA matters most. For servers, the best rule is: no passwords for SSH at all (keys only).
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
| New rules do not apply to old users | login.defs affects only new users. | Use chage for existing users (Ansible for many). |
| Root can still set weak passwords | pwquality only warns for root. | enforce_for_root. |
| Changes to PAM files are overwritten (RHEL) | authselect manages PAM. | Use authselect features / custom profiles, not manual edits. |
| A user is locked and can not work | faillock lockout. | faillock --user USER --reset; check what made the failures (a script with an old password?). |
| Service accounts expire and jobs stop | Expiry set on service accounts. | chage -M -1 svcuser (and no password login for them at all). |
| Ubuntu: rules have no effect | libpam-pwquality not installed. | apt-get install libpam-pwquality. |
Go further
- Command pages: chage, passwd, usermod.
- Next how-tos: Lock or disable a user account, Create a user with sudo rights, Harden the SSH server.
- Learn it: RHCSA — Password aging, RHCSA — Defaults, RH124 — Passwords.
- Audit tools: Lynis, OpenSCAP.
- Practise: Lab: create users and groups with password rules.
1Why do changes in /etc/login.defs not affect existing users?
They are defaults for new accounts; existing users need chage.
2Which tool locks an account after too many failed logins?
pam_faillock (/etc/security/faillock.conf, check with faillock --user).