When you use the passwd
command to change the password of a Linux ECS instance, you might receive the passwd: Module is unknown
and passwd: password unchanged
error messages. This failure typically indicates a problem with the Pluggable Authentication Modules (PAM) configuration. This can happen if necessary PAM modules are missing or incorrectly configured. PAM is a framework of modules in Linux used to manage user authentication.
Problem description
Symptom 1: You cannot change the password of a Linux ECS instance using the passwd
command. The following error message is returned:
passwd: Module is unknown
passwd: password unchanged
Symptom 2: You cannot reset the password of the Linux ECS instance using Cloud Assistant. The following error messages appear.
Possible causes
PAM modules are not installed or are missing: A required PAM module, such as
pam_unix.so
orpam_pwquality.so
, is missing. This can happen if the module file was accidentally deleted or is corrupted.PAM configuration file errors: A configuration file in the
/etc/pam.d/
folder, such ascommon-password
orsystem-auth
, references a module that does not exist. This can also happen if the module path or parameters in the configuration file are incorrect.Password policy configuration issues: The
/etc/security/pwquality.conf
file is configured incorrectly. This causes thepam_pwquality.so
module to fail.
Solution
Step 1: Check if the pam_unix.so
module exists
Connect to the Linux ECS instance.
For more information, see Use Workbench to connect to a Linux instance over SSH.
Run the following command to check whether the
pam_unix.so
module exists.sudo find / -name "pam_unix.so"
NoteIf
pam_unix.so
exists, proceed to Check the pam_pwquality.so module configuration.If
pam_unix.so
does not exist, the system library file might be damaged or the PAM-related package is not installed. Thepam_unix.so
module is a core PAM component responsible for basic user authentication and password management. In this case, you must reinstall the PAM package.
Re-install the PAM package.
Ubuntu or Debian
sudo apt-get update sudo apt-get install --reinstall libpam-modules
CentOS, Red Hat Enterprise Linux (RHEL), or Alibaba Cloud Linux
sudo yum reinstall pam
Run the following command again to check whether
pam_unix.so
exists.sudo find / -name "pam_unix.so"
Step 2: Check the pam_pwquality.so
module configuration
The pam_pwquality.so
module enforces password complexity rules, such as minimum length and character types. If the pam_pwquality.so
module is enabled, passwords must meet the defined rules.
Check the system logs for error messages related to
pam_pwquality.so
, such asModule is unknown
orpam_chauthtok() failed
.Ubuntu or Debian
sudo tail -f /var/log/auth.log
CentOS, RHEL, or Alibaba Cloud Linux
sudo tail -f /var/log/secure
NoteThe following error messages appear:
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.so
The log indicates that the system cannot load the
pam_pwquality.so
module. This error can occur if thepam_pwquality.so
module is not installed or if the installation path is incorrect.
Run the following command to check whether
pam_pwquality.so
is installed.sudo find / -name "pam_pwquality.so"
The following command output indicates that the module is installed:
/usr/lib/x86_64-linux-gnu/security/pam_pwquality.so
Step 3: Verify that the configuration is effective
Change the password and verify that the change is in effect.
passwd