尝试将(不存在的)用户添加到我的 CentOS 系统时返回useradd: user example exists. 我可以成功地手动将用户添加到 /etc/passwd 和 /etc/shadow,但这种解决方法是一件坏事。用户存在于 LDAP 中,但 PAM 未使用 LDAP 进行身份验证。添加其他用户工作正常。我难住了。
预计到达时间:
[root ~]# userdel example
userdel: error deleting password entry
userdel: error deleting shadow password entry
[root ~]# useradd example
useradd: user example exists
[root ~]# su example
bash-3.2$ whoami
example
bash-3.2$ groups example
example : Users
bash-3.2$ cd
bash: cd: /home/example: No such file or directory
bash-3.2$
Run Code Online (Sandbox Code Playgroud) 我/etc/passwd为非 root 用户手动编辑- 是的,我知道这很糟糕。不幸的是,我很晚才看到这一点(手动编辑 /etc/passwd 和 /etc/shadow 后 SSH 验证失败)。我已经恢复/etc/passwd到以前的状态,但是服务器上发生了一些奇怪的事情,例如:
useradd some_user
Run Code Online (Sandbox Code Playgroud)
不会为此用户创建主目录,也不会询问密码,旧用户的授权不起作用。我希望有人已经遇到过这样的问题。PS我使用Debian