Problem description
After you reset the root password of a Linux ECS instance in the ECS console, you cannot log on with the new password.
Cause
The i (Immutable) attribute is set on the /etc/passwd or /etc/shadow file, which prevents the new password from taking effect.
In Linux, /etc/passwd stores account information and /etc/shadow stores password information. Incorrect file attributes on /etc/shadow or /etc/passwd can cause unexpected behavior, for example, a password reset not taking effect. See Common chattr attributes.
Solution
-
Connect to the Linux ECS instance as the root user. See Use Workbench to connect to a Linux instance over SSH.
ImportantUse the original valid password to connect. If the original password is also invalid, connect to the instance by using VNC.
-
Run the following commands to check file attributes:
# Check the attribute status of the passwd file. lsattr /etc/passwd # Check the attribute status of the shadow file. lsattr /etc/shadow-
If no special flag such as
ioraappears, the attributes are normal. -
Sample abnormal status:
[root@iZbp1b0xxx ~]# lsattr /etc/passwd ----i------------ /etc/passwdThe
iflag indicates that the/etc/passwdfile has the immutable attribute.
-
-
If abnormal attributes exist, run the following commands to remove them:
# Remove the immutable attribute from the passwd file chattr -i /etc/passwd # Remove the append only attribute from the shadow file chattr -a /etc/shadow -
Recheck file attributes:
lsattr /etc/passwd /etc/shadowThe output should not contain the
ioraflag. -
Reset the root password in the ECS console. See Reset the logon password of an instance.
-
Log on with the new root password. If the connection succeeds, the issue is resolved.
Appendix
Common chattr attributes
|
Attribute |
Full name |
Description |
Common scenario |
|
i |
Immutable |
The file cannot be modified, deleted, renamed, or linked. |
Protect critical system files from tampering. |
|
a |
Append Only |
Only appending is allowed. Existing content cannot be modified. |
Protect log file integrity. |
|
e |
Extent Format |
The file uses extents for disk block mapping. This is the default on modern file systems and requires no manual change. |
Automatic system management. |
|
A |
No Atime Updates |
Access time (atime) is not updated when the file is read, reducing disk I/O. |
High-concurrency server optimization. |