The sys admin's daily grind: pwquality
Charly's Column – pwquality

Regular password changes are a thing of the past: Strong passwords for each individual service provide more protection. Charly pimped his Ubuntu accordingly with a suitable PAM module.
Changing the password regularly, about every 60 or 90 days, is now considered obsolete. It is better to use a separate strong password for each service and each login. The requirement for how strong (i.e., how complicated) a password must be is something that – at least on your own systems – you can define yourself.
On my test machine with Ubuntu, I can use almost any simple password I want – that has to change. To make sure it does, I first have to install the pwquality PAM library:
$ sudo apt install libpam-pwquality
Then I have to add a line to the /etc/pam.d/common-password
configuration file. On Ubuntu 18.04 "Bionic Beaver," the default looks like this (this may be slightly different on other systems):
password [success=1 default=ignore] pam_unix.so obscure sha512
This line can remain as a fallback, but in front of it – and this is important – I need to insert the line from Listing 1. This is a single line, which I just wrapped for Listing 1 to improve readability. With the individual parameters (Table 1 breaks them down), the password requirements can be easily controlled.
Listing 1
Password Requirements
password requisite pam_pwquality.so \ retry=4 minlen=9 difok=4 lcredit=-2 \ ucredit=-2 dcredit=-1 ocredit=-1 \ reject_username enforce_for_root
Table 1
pwquality Parameters
Parameter |
Meaning |
retry |
Number of incorrect attempts |
minlen |
Minimum password length |
difok |
Number of characters that can match the old password |
lcredit |
Minimum number of lowercase letters |
ucredit |
Minimum number of uppercase letters |
dcredit |
Minimum number of numbers |
ocredit |
Minimum number of non-standard characters |
reject_username |
Password and username cannot be identical |
enforce_for_root |
Rules also apply for root |
After restarting the system, the new password rule takes effect. To test it, I changed the password of the user bob (Figure 1). In doing so, I intentionally entered a password that was too short in the first round and one that can be found in common dictionaries in the second. The system categorically rejected both – and that's the way it should be.
As my third attempt, I entered a new password that complied with the modified rules: Cm1.Sya-n
. This seems complicated, but it is mnemonic. It's the first letters and punctuation of the first words of Melville's Moby Dick [1], with a 1 instead of an I, because I need a digit according to the new password rule. The system accepted the password without complaint.
Infos
- "Call me Ishmael. Some years ago – never mind how long precisely …": http://www.online-literature.com/melville/mobydick/2/
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

News
-
First Release Candidate for Linux Kernel 6.14 Now Available
Linus Torvalds has officially released the first release candidate for kernel 6.14 and it includes over 500,000 lines of modified code, making for a small release.
-
System76 Refreshes Meerkat Mini PC
If you're looking for a small form factor PC powered by Linux, System76 has exactly what you need in the Meerkat mini PC.
-
Gnome 48 Alpha Ready for Testing
The latest Gnome desktop alpha is now available with plenty of new features and improvements.
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.