The sys admin's daily grind: pwquality
Strong Passwords
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 this article as PDF
(incl. VAT)
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
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.