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

Car*_*jas 20 password sudo

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

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

如果没有,我该如何更改sudo密码?

Áng*_*gel 45

默认情况下,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.
Run Code Online (Sandbox Code Playgroud)

同样,要求 sudo 密码的关键字是NOPASSWD

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

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

  • 您还应该提到如何设置 `root` 密码。将 `sudo` 配置为需要 `root` 密码而不先设置 `root` 密码可能会有问题。 (9认同)
  • 虽然这是真的,但让管理员知道“root 密码”通常被认为是一个坏主意。考虑更改它然后离开的管理员可能造成多大的损害。最佳实践通常要求管理员成为 `/etc/sudoers` 中的组(例如“wheel”)的成员,该组可以使用自己的密码而不是共享密码提升为 root。 (4认同)

小智 22

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

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

  • 这就是 `sudo` 通常默认配置的方式。但该配置可以更改。 (8认同)

ica*_*rus 3

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