When you use the passwd command to change the password of a Linux ECS instance, you may receive the passwd: Module is unknown and passwd: password unchanged errors. These errors typically indicate a problem with the Pluggable Authentication Modules (PAM) configuration, such as a missing or misconfigured PAM module. PAM is a framework that Linux systems use to manage user authentication.
Symptoms
The passwd command fails, and the following message is returned:
passwd: Module is unknown
passwd: password unchanged
An attempt to reset the instance password online by using Cloud Assistant fails, and the following message is returned:
Key pair [t-zjk5191zbypjytc] has been removed
chpasswd: (user root) pam_chauthtok() failed, error:
Module is unknown
chpasswd: (line 1, user root) password not changed
Password reset failed.
Possible causes
-
PAM module not installed or missing: A required PAM module, such as
pam_unix.soorpam_pwquality.so, is missing, deleted, or corrupted. -
Incorrect PAM configuration file: A PAM configuration file in the
/etc/pam.d/directory, such ascommon-passwordorsystem-auth, references a nonexistent module or contains an incorrect module path or parameters. -
Incorrect password policy configuration: The
/etc/security/pwquality.conffile is misconfigured, which prevents thepam_pwquality.somodule from working correctly.
Solution
Step 1: Check pam_unix.so
-
Connect to your Linux instance.
For more information, see Log on to a Linux instance by using Workbench.
-
Check if the
pam_unix.somodule exists:sudo find / -name "pam_unix.so"Note-
If
pam_unix.soexists, proceed to Step 2: Check the pam_pwquality.so configuration. -
If
pam_unix.sodoes not exist, its parent package may be missing or the system library files may be corrupted. Reinstall the PAM package. Thepam_unix.somodule is a core PAM module that handles basic user authentication and password management.
-
-
Reinstall the required PAM package.
-
Ubuntu/Debian
sudo apt-get update sudo apt-get install --reinstall libpam-modules -
CentOS/RHEL/Alibaba Cloud Linux
sudo yum reinstall pam
-
-
Run the following command again to verify that
pam_unix.soexists.sudo find / -name "pam_unix.so"
Step 2: Check the pam_pwquality.so configuration
The pam_pwquality.so module is used to enhance password complexity checks, such as minimum length and character types. If pam_pwquality.so is enabled on the system, users must meet its defined complexity rules when changing their passwords.
-
Check the system log for error messages related to
pam_pwquality.so, such asModule is unknownorpam_chauthtok() failed.-
Ubuntu/Debian:
sudo tail -f /var/log/auth.log -
CentOS/RHEL/Alibaba Cloud Linux:
sudo tail -f /var/log/secureNoteFor example, the following error message may be returned:
PAM unable to dlopen(pam_puquality.so): /lib/security/pam_puquality.so: cannot open shared object file: No such file or directory PAM adding faulty module: pam_puquality.soThe log shows that the system failed to load the
pam_pwquality.somodule. This may be because thepam_pwquality.somodule is not installed or the installation path is incorrect.
-
-
Run the following command to check if
pam_pwquality.sois installed.sudo find / -name "pam_pwquality.so"If the output resembles the following, the module is installed.
/usr/lib/x86_64-linux-gnu/security/pam_pwquality.so -
-
Step 3: Verify the fix
Try changing the password again to verify the fix.
passwd