Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 116Security · Users

How to set password rules and expiry

Audits (ISO 27001, PCI, internal policies) ask: how long must passwords be, how often do they expire, what happens after wrong tries? On Linux three parts answer this: pwquality (strength), chage / login.defs (age), and faillock (lockout after failed logins). This how-to sets all three on RHEL and Ubuntu and checks them.

  • 5 Lessen
  • 4 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

116.1

The quick answer

/etc/security/pwquality.conf.d/10-policy.conf
minlen = 14
minclass = 3
dictcheck = 1
chage -M 90 -m 1 -W 14 alice
chage -l alice
authselect enable-feature with-faillock
faillock --user alice

authselect is for RHEL; on Ubuntu install libpam-pwquality (strength) and configure pam_faillock (lockout).

Commando's in deze les

116.2

Step by step

  1. Strength — pwquality checks new passwords:
SettingMeans
minlen = 14At least 14 characters.
minclass = 3At least 3 of: lower, upper, digit, other.
dictcheck = 1Reject dictionary words.
usercheck = 1Reject passwords with the user name.
enforce_for_rootAlso for root (otherwise root gets only a warning).
  1. 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.

  1. Defaults for new users in /etc/login.defs (only users created after the change):
/etc/login.defs (part)
PASS_MAX_DAYS   90
PASS_MIN_DAYS   1
PASS_WARN_AGE   14
  1. Lockout after failed logins (faillock):
/etc/security/faillock.conf
deny = 5
unlock_time = 900
fail_interval = 900
authselect enable-feature with-faillock
faillock --user alice
faillock --user alice --reset

5 failures in 15 minutes lock the account for 15 minutes; --reset unlocks it at once.

  1. 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).

Commando's in deze les

116.3

Check that it worked

passwd
New password: short
BAD PASSWORD: The password is shorter than 14 characters
chage -l alice | head -4
faillock --user alice

A weak password is refused, the age rules are set, and failed logins are counted.

116.4

Common problems

ProblemCauseFix
New rules do not apply to old userslogin.defs affects only new users.Use chage for existing users (Ansible for many).
Root can still set weak passwordspwquality 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 workfaillock lockout.faillock --user USER --reset; check what made the failures (a script with an old password?).
Service accounts expire and jobs stopExpiry set on service accounts.chage -M -1 svcuser (and no password login for them at all).
Ubuntu: rules have no effectlibpam-pwquality not installed.apt-get install libpam-pwquality.

Commando's in deze les

116.5

Go further

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).

Alle commando's in dit hoofdstuk