Scenario
You are auditing password policy enforcement on a Linux host. A test account named expiringuser
must be created and configured with password aging rules to meet internal standards. You will enforce expiration,
minimum change windows, and warning periods, confirm the settings with a policy report, then disable aging and remove
the account.
This is the workflow you use to prove password aging is actually enforced, not just set in policy text somewhere.
Objective
- Create a user account for testing policy.
- Set a password and enable password expiration rules.
- Configure minimum age and expiration warning window.
- Inspect the resulting policy state with
chagereporting. - Disable password aging and clean up the user.
Concepts
-
Password aging is stored per-user and can be inspected as evidence using
chage. - Maximum age determines when a password expires. Minimum age prevents immediate re-changes after a rotation.
- Warning days determine when pre-expiration notices begin before the expiry date.
- Disabling aging should be deliberate and validated, especially on service accounts.
Walkthrough
sudo useradd expiringuser
Create a dedicated account so the policy changes are isolated and easy to inspect.
sudo passwd expiringuser
Password aging targets password metadata. Set a password first so the last password change field is meaningful.
sudo chage -M 30 expiringuser
Maximum age controls how long a password can remain valid before the user must change it.
sudo chage -m 7 expiringuser
Minimum age prevents rapid password cycling and supports stronger password rotation enforcement.
sudo chage -W 5 expiringuser
Warning days control when users begin receiving expiration warnings prior to password expiry.
sudo chage -l expiringuser
This is your proof step. It prints the effective aging configuration attached to the user account.
Last password change : Jul 18, 2025
Password expires : Aug 17, 2025
Password inactive : never
Account expires : never
Minimum number of days between password change : 7
Maximum number of days between password change : 30
Number of days of warning before password expires: 5
sudo chage -M -1 expiringuser
Setting max age to -1 disables expiration. Validate the result by re-checking the policy report.
sudo chage -l expiringuser
sudo userdel expiringuser
Remove the user once verification is complete so the host returns to a clean baseline state.
Breakpoints
If you run chage before setting a password, the policy output may be confusing because the last-change
field is not meaningful. Set the password with passwd and re-check with chage -l.
Password aging is only one layer. Login restrictions may also depend on PAM and account state.
Confirm the user is not locked and verify policy again using chage -l.
This lab uses userdel without removing the home directory. If you created a home directory and want it removed,
use userdel -r.
Cleanup checklist
- Confirm the account no longer exists in the passwd database.
- Confirm there are no leftover processes owned by the test user.
getent passwd expiringuser
ps -u expiringuser
Reference
useradd: Creates a new user.passwd: Sets or changes a user password.-
chage: Manages password aging information.-M: Set maximum password age in days.-m: Set minimum password age in days.-W: Set warning days before expiration.-l: List current aging settings.
userdel: Deletes a user account.getent: Queries system databases.ps: Lists processes.-u: Select processes by effective user.