1. 程式人生 > >Linux系統下root使用者執行passwd修改密碼時報錯Authentication token manipulation error

Linux系統下root使用者執行passwd修改密碼時報錯Authentication token manipulation error

今天準備修改Linux系統的root使用者密碼時,執行passwd root,出現了以下情況,修改密碼失敗:

# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: Authentication token manipulation error

到網上搜了下,有的說是因為inodes用完,也就是根分割槽滿了引起的,但執行df -i並非找個原因:

# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 6406144 58534 6347610 1% /
tmpfs 8242797 2 8242795 1% /dev/shm

繼續找答案,按照網上的案例檢查使用者密碼相關的系統檔案/etc/passwd和/etc/shadow,發現這兩個檔案許可權有i選項,查詢結果如下:

# lsattr /etc/passwd
—-i——–e- /etc/passwd
# lsattr /etc/shadow
—-i——–e- /etc/shadow

備註:在Linux系統裡,檔案有i選項則表示不得對其做任何的修改,這也就導致了修改密碼失敗。

要解決該問題,則需要執行chattr -i命令,將以上兩個檔案i許可權撤銷掉

# chattr -i /etc/passwd
# chattr -i /etc/shadow
# lsattr /etc/passwd
————-e- /etc/passwd
# lsattr /etc/shadow
————-e- /etc/shadow

然後再執行passwd修改密碼,

# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

修改完密碼後,為了安全起見,可以執行chattr +i為使用者密碼系統檔案增加i許可權

# chattr +i /etc/passwd
# chattr +i /etc/shadow
# lsattr /etc/passwd
—-i——–e- /etc/passwd
# lsattr /etc/shadow
—-i——–e- /etc/shadow