我在 VirtualBox 中创建了 Ubuntu 服务器并创建了其他用户。然后用 锁定它passwd -l user
。然后当我尝试 ssh 该用户时,它不断要求输入密码,但即使我输入了锁定前存在的密码,它似乎也是无效的。我是 Ubuntu 新手,所以我有点困惑。
答案1
密码锁定并不意味着系统不会要求输入密码。它会要求输入密码,但不可能输入正确的密码并登录。这就是它的工作原理。如果您解锁密码,旧密码将被重置。
从man passwd
:
-l, --lock
Lock the password of the named account. This option disables a password by changing it to a value which matches no possible encrypted value (it
adds a ´!´ at the beginning of the password).
Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key). To
disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970).
-u, --unlock
Unlock the password of the named account. This option re-enables a password by changing the password back to its previous value (to the value
before using the -l option).
我不确定手册上说!
在密码开头添加一个是否正确,我认为它将其添加!
到了哈希值的开头/etc/shadow
。如果我错了,请纠正我。
答案2
好吧,最后我找到了问题的根源。实际上,我的权限完全搞乱了,因为我从 sudo 创建了 .ssh/authorized_keys,并且 chmod 700 sat 权限只允许超级用户读取和更改权限...
此外,我需要 ssh 主机将其添加到 list_of_known_hosts