Linux – How to disable “password contains the user name” restriction in centos 7

centoslinuxpasswords

My username is z, and my password contains z, and the system disallow me to use that password. The error is:

BAD PASSWORD: The password contains the user name in some form.

This is an error and I cannot get pass through. I Googled about this problem but cannot find any working answer. These are the things I tried:

  • Call passwd from root.
  • Change /etc/pam.d/system-auth and /etc/pam.d/password-auth: from requisite to optional on pam_pwquality.so or comment out that line. Commenting out result in error "passwd: Authentication token manipulation error".
  • Check /usr/sbin/authconfig –help, find no related option.
  • Change /etc/security/pwquality.conf, find no related option. Tried gecoscheck=0, didn't make any different.

Can anyone help me?

Best Answer

Checking libpwquality code on github it looks like error message you get comes from this library. Probably called from PAM module, so you should start checking what you have in /etc/pam.d/passwd by default for password it only includes /etc/pam.d/system-auth. I think you were quite close, however, setting module as optional didn't work for you. I'd suggest commenting it out for test and setting gecoscheck=N either in pam or /etc/security/pwquality.conf

Simply commenting out the line in /etc/pam.d/system-auth may not work, however, you can try to update the file password section to something like this (only password section matters): password sufficient pam_unix.so sha512 password required pam_deny.so After that simply execute passwd user at try your favourite password. For me setting exectly the same user name and password worked, which is obviously not recommended from the system security perspective.

Related Question