1. 程式人生 > >Linux 修改密碼“ Authentication token manipulation err”

Linux 修改密碼“ Authentication token manipulation err”

發現 swd lac 解決 tor 出錯 red contain erro

修改服務器root密碼 錯誤 “passwd: Authentication token manipulation error”

百度了各種解決方案


總結 1. 權限問題

lsattr  /etc/passwd/      -------------e- /etc/passwd

lsattr /etc/shadow/      -------------e- /etc/passwd

用lsattr命令查看存放用戶和密碼的文件屬性,發現有i選項: (i:不得任意更動文件或目錄。)所以導致所有的用戶都不能修改密碼,因為沒有權限允許。
這種情況我們需要用chattr命令將i權限撤銷,然後再修改

總結 2 .  ``同步/etc/passwd 和/etc/shadow出錯
 #pwconv
pwconv: can‘t lock passwd file

我的沒有這個報錯

總結3
看權限沒有異常,也沒有進程鎖定該文件
ll /etc/passwd
文件權限已經開到最大

cp lock文件出錯,提示空間不足
cp  /tmp/.pwd.lock  /etc

以上均沒有報錯

再次修改密碼仍然出錯,於是嘗試修改/etc/passwd也出現錯誤
最後懷疑系統版本問題,centos7開始 對這個文件有保護

於是查找centos7報該錯誤的解決方案,果然有很多猿類都遇到該問題

是selinux導致的
關閉selinux就可以修改密碼了
/usr/sbin/setenforce 0 立刻關閉 SELINUX

/usr/sbin/setenforce 1 立刻啟用 SELINUX

但是嘗試後仍然無法修改密碼

最終總結

down vote
accepted
It‘s failing because passwd manipulates a temporary file, and then attempts to rename it to /etc/shadow. This fails because /etc/shadow is a mountpoint -- which cannot be replaced -- which results in this error (captured using strace):

102 rename("/etc/nshadow", "/etc/shadow") = -1 EBUSY (Device or resource busy)

You can reproduce this trivially from the command line:

cd /etc

touch foo

mv foo shadow

mv: cannot move ‘foo‘ to ‘shadow‘: Device or resource busy
You could work around this by mounting a directory containing my_shadow and my_passwd somewhere else, and then symlinking /etc/passwd and /etc/shadow in the container appropriately:

$ docker run -it --rm -v $PWD/my_etc:/my_etc centos
[root@afbc739f588c /]# ln -sf /my_etc/my_passwd /etc/passwd
[root@afbc739f588c /]# ln -sf /my_etc/my_shadow /etc/shadow
[root@afbc739f588c /]# ls -l /etc/{shadow,passwd}
lrwxrwxrwx. 1 root root 17 Oct 8 17:48 /etc/passwd -> /my_etc/my_passwd
lrwxrwxrwx. 1 root root 17 Oct 8 17:48 /etc/shadow -> /my_etc/my_shadow
[root@afbc739f588c /]# passwd root
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@afbc739f588c /]#

Linux 修改密碼“ Authentication token manipulation err”