gpt4 book ai didi

linux - linux下如何解锁用户sudo的密码?

转载 作者:太空宇宙 更新时间:2023-11-04 05:18:04 25 4
gpt4 key购买 nike

我是 Linux (Ubuntu) 的唯一用户 - admin(sudo 用户)。

我已将自己屏蔽,如下:

 $ sudo passwd -l admin

帮我解锁自己。

我(用户管理员)无法解锁密码:

  $ ssh admin@remotehost "sudo passwd -u admin"
sudo: no tty present and no askpass program specified

$ ssh -t admin@remotehost "sudo passwd -u admin"
[sudo] password for admin:
Sorry, try again.
[sudo] password for admin:
Sorry, try again.
[sudo] password for admin:
sudo: 3 incorrect password attempts
Connection to remotehost closed.

最佳答案

根据passwd的手册页,当您指定选项-l时,/etc/shadow文件会被更新。

-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).

Users with a locked password are not allowed to change their
password.

据我们所知,密码锁定的用户不允许更新其密码。其他用户必须更新 /etc/shadow 文件才能解锁帐户。

就您而言,您需要对服务器进行物理访问,然后您必须在实时 CD/USB linux 上启动并编辑 /etc/shadow 文件以删除 ! 字符。如果您没有此类访问权限,请联系您的提供者以检查是否存在某些恢复选项(Web tty、备份、人工干预等)

关于linux - linux下如何解锁用户sudo的密码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46112052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com