1.7 KiB
1.7 KiB
Using Linux Terminal 3.3: Password complexity and expiry
Password rules with pam_pwquality, aging and account expiry for one user, and aging defaults for new accounts.
Before you start
Work as root (sudo -i). The lab creates users alice and pwtest
(password Lab-Pass-1); try passwords out on pwtest, for example echo 'pwtest:lowercase12' | chpasswd, so alice's settings from task 2 stay as
you made them. The rules only apply when a password is set, so they can't
lock anyone out of logging in. The lab saves /etc/pam.d/common-password,
the pwquality settings and /etc/login.defs, and puts them back on reset;
reset also removes libpam-pwquality again if the lab started without it,
and user dave if you made him.
Tasks
- Install pam_pwquality and require passwords of at least 10 characters
with at least one digit and one uppercase letter, for every user
including root.
echo 'pwtest:lowercase12' | chpasswdfails with "BAD PASSWORD: The password contains less than 1 uppercase letters", andecho 'pwtest:Kettle7-Harbor' | chpasswdsucceeds. - Make alice's password expire every 60 days with 10 days' warning, disable her account on the last day of next year, and make her choose a new password at her next login.
- Make new accounts' passwords expire after 120 days, without changing
existing users. After
useradd -m dave,chage -l daveshows maximum 120, andchage -l aliceis unchanged.
Hints
apt install libpam-pwquality; a file in/etc/security/pwquality.conf.d/(make the directory) withminlen,dcredit = -1,ucredit = -1andenforce_for_root.chage -M -W -E -d 0; check withchage -l alice.PASS_MAX_DAYSin/etc/login.defs.