Step 7 of 8 · lab · 30 min
A password can be anything
Interns change their own passwords and the system accepts any of them, while guessing a password can go on forever. Introduce a password policy and a lockout after failed attempts without losing your own key login and sudo.
Situation
Interns are joining the server team. Their accounts are created with a temporary password, and after that everyone
changes it themselves with passwd. The intern intern set the password qwerty12 — the system did not object.
Guessing a password can go on forever too: wrong passwords in su have no consequences.
You are the administrator: you log in with a key (ssh localhost) and work through sudo. The intern's account is
handy for checking the result: su - intern, password qwerty12.
Task
- With
passwd, a user cannot set a password shorter than 12 characters or with fewer than three character classes (lowercase, uppercase, digits, others). A password that follows these rules is accepted. - The rules are written in
/etc/security/pwquality.conf(or in a file in/etc/security/pwquality.conf.d/) —pwscoresees them. - After three wrong passwords in a row the account is locked for any password login: the console,
su,sudo. A successful login before the lockout resets the counter. - Your own access is intact: student's key login,
sudoand the console login work as before.
A mistake in
/etc/pam.dcan close both logins andsudo. Edit PAM from a root shellsudo -iand do not leave it untilsu - student -c 'sudo -n true'finishes without an error. There is no internet on the machine; everything you need is already installed.
Lab · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
Goals
0 of 4-
pwscore rejects passwords shorter than 12 characters or with fewer than three classes and accepts a compliant one — not done yet
-
passwd does not let a user set a weak password and accepts a compliant one — not done yet
-
Three wrong passwords in a row lock the account for any password login, and a successful login resets the counter — not done yet
-
student logs in with the key, and sudo and the console login work as before — not done yet
The machine is starting
Hints
0 of 3Lab goals
0 of 4-
pwscore rejects passwords shorter than 12 characters or with fewer than three classes and accepts a compliant one — not done yet
-
passwd does not let a user set a weak password and accepts a compliant one — not done yet
-
Three wrong passwords in a row lock the account for any password login, and a successful login resets the counter — not done yet
-
student logs in with the key, and sudo and the console login work as before — not done yet
Goals are checked on the machine after every command.