TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashLinux

How to configure password complexity in Ubuntu

This article explains the steps to configure password policies in Ubuntu.

Step1: Login to the machine as root.

Step2: Install the pwquality package.

#apt install libpam-pwquality

Step3: Open "/etc/pam.d/common-password".

#vi /etc/pam.d/common-password

Step4: Find the following line.

Password   requisite   pam_pwquality.so retry=3

Step5: Replace it with the following line and save.

password   requisite   pam_pwquality.so retry=3 minlen=12 maxrepeat=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 difok=4 reject_username enforce_for_root

Notes:

retry: No. of consecutive times a user can enter an incorrect password.
minlen: Minimum length of password
difok: No. of character that can be similar to the old password
lcredit: Min No. of lowercase letters
ucredit: Min No. of uppercase letters
dcredit: Min No. of digits
ocredit: Min No. of symbols
reject_username: Rejects the password containing the user name
enforce_for_root: Also enforce the policy for the root user

Step6: Reboot the system to apply the changes.

That's all…