Friday, October 11, 2024

Set enforce complex password Ubunut 22.04

1) Install the libpam-pwquality package
sudo apt update
sudo apt install libpam-pwquality
2) Edit the PAM password configuration file  open the /etc/pam.d/common-password file for editing:
sudo nano /etc/pam.d/common-password
3) Add or modify the pwquality settings:
password requisite pam_pwquality.so retry=3
password requisite pam_pwquality.so retry=3 minlen=12 dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1
retry=3: Allows 3 retries if the user enters an invalid password.
minlen=12: Requires a minimum password length of 12 characters.
dcredit=-1: Requires at least 1 digit.
ucredit=-1: Requires at least 1 uppercase letter.
lcredit=-1: Requires at least 1 lowercase letter.
ocredit=-1: Requires at least 1 special character (e.g., @, #, $).
4) Optional: Add additional password strength rules:
sudo nano /etc/security/pwquality.conf
Here you can add options like:
minlen = 12
dcredit = -1
ucredit = -1
lcredit = -1
ocredit = -1
maxrepeat = 2       # Prevent repeated characters
maxclassrepeat = 2  # Prevent excessive character class repetition
5) Save and exit: After editing
6) Test the configuration: 
sudo passwd <username>
Ref
  • https://chatgpt.com/share/6708c50a-d480-8010-8ea4-418483178302

No comments:

Post a Comment

Popular Posts