更改某个用户的密码是否也会更改 sudo 密码?

更改某个用户的密码是否也会更改 sudo 密码?

我是 Linux Mint 系统的唯一用户,我注意到我选择登录的密码与分配给 的密码相同sudo

所以我的问题是:更改我的登录密码也会更改sudo密码吗?

如果不是,我该如何更改sudo密码?

答案1

默认情况下,sudo要求用户密码。因此,更改用户密码(也用于登录)也会影响 sudo 调用。

/etc/sudoers但是,您可以为您的用户设置rootpw标志,在这种情况下,它会要求输入 root 密码。

相关摘录自sudoers(5) 手册页是:

Authentication and logging
 The sudoers security policy requires that most users authenticate them‐
 selves before they can use sudo.  A password is not required if the
 invoking user is root, if the target user is the same as the invoking
 user, or if the policy has disabled authentication for the user or com‐
 mand.  Unlike su(1), when sudoers requires authentication, it validates
 the invoking user's credentials, not the target user's (or root's) cre‐
 dentials.  This can be changed via the rootpw, targetpw and runaspw
 flags, described later.

同样,关键字为不是请求 sudo 的密码是无密码WD

如果你想设置root密码,可以使用sudo passwd

请注意,更改 sudo 权限时,建议保持根控制台打开(例如sudo -s),直到在不同的终端中验证它确实有效,并且您没有锁定自己。

答案2

sudo它本身没有密码。一个用户可以属于该sudo组并运行该sudo命令,但每个用户只有一个密码。当它发生变化时,它会为用户而变化,而不是针对任何特定的应用程序。

另一个类似的误解是 root 密码与用于sudoing 的密码相同。不,是单个用户,有一个私人密码,与任何其他密码无关。

答案3

是的,sudo使用相同的“密码数据库”(通常/etc/shadow用于小型系统)作为登录。

相关内容