How To Set User Password Policy On CentOS 7
This is important to change the default password policy on the Linux system. By default, there’s no password policy applied in Linux and So you can set user password policy by editing in those files /etc/pam.d/system-auth and /etc/pam.d/password-auth.
Check Out : How To Check User Account Locked or Not In Linux
You can force user to change their password at first login with chage command and also set the expiration on user account. To check, all the information about user, use this command lslogins usename.
Carefully change these settings in the files, i would suggest you to try this settings on a user before applying on the root users. User management plays a vital role in Linux. you should not that.
You may find all the files here /etc/pam.d/
Requirement 1 : set the minimum length, insert the below line if does not exist in this file vim /etc/security/pwquality.conf
minlen = 9
Requirement 2 : keep the history of password used on the system and you need to insert the below line in this file /etc/pam.d/system-auth and /etc/pam.d/password-auth (after pam_pwquality.so line).
password requisite pam_pwhistory.so remember=5 use_authtok
Check Out : Create User And Group Using Command line
Requirement 3 : After enabling pam_pwquality.so in password-auth and system-auth, now add these parameters in /etc/security/pwquality.so
minlen = Minimum length
dcredit = Minimum credit for having required digit in password
ucredit = Minimum credit for having uppercase character in password
ocredit = Minimum credit for having other character in password
lcredit = Minimum credit for having lowercase character in password
Requirement 4 : you can also force root to password complexity by edting in this file /etc/security/pwquality.conf