Course contentsShow
← Security
Lesson 1427 of 3,05229. Operating System Security - HardeningFree lesson

Password Policies and Account Security

Implementing password complexity, expiration, history requirements using PAM and system policies.

Password Policies and Account Security

What you'll learn: How to enforce strong password requirements and protect accounts from compromise using PAM and system-level policies.

Why Password Policies Matter

Even with the least privilege and perfect file permissions, weak passwords are an open door for attackers. Password policies automate the enforcement of security requirements—like complexity, expiration, and history—so humans don't have to remember (or forget) the rules.

Using PAM for Password Control

PAM (Pluggable Authentication Modules) is Linux's authentication framework. The pam_pwquality module enforces password strength:

# Edit /etc/security/pwquality.conf
minlen = 14           # Minimum length
dcredit = -1          # At least one digit
ucredit = -1          # At least one uppercase
lcredit = -1          # At least one lowercase
ocredit = -1          # At least one special character

Password Expiration and History

Prevent password reuse and force periodic changes:

# /etc/login.defs
PASS_MAX_DAYS   90    # Expire after 90 days
PASS_MIN_DAYS   1     # Can't change twice in one day
PASS_WARN_AGE   7     # Warn 7 days before expiration

# In PAM configuration
# Remember last 5 passwords (prevents reuse)
password required pam_pwhistory.so remember=5

For existing users, apply with chage:

sudo chage -M 90 -m 1 -W 7 username

Account Lockout Protection

Protect against brute-force attacks by locking accounts after failed attempts:

# In /etc/pam.d/common-auth
auth required pam_faillock.so deny=5 unlock_time=900

This locks accounts for 15 minutes after 5 failed login attempts.

Key Takeaway: Password policies implemented through PAM and system configuration files enforce complexity, expiration, and history requirements automatically—turning security best practices into technical controls that protect every account without relying on user discipline.