即使使用 NOPASSWD 编辑了 sudoers,仍会提示输入 root 密码

即使使用 NOPASSWD 编辑了 sudoers,仍会提示输入 root 密码

我正在尝试配置我的 sudoers 文件,以便每次我需要访问 root 权限时都不会提示我输入密码。

我仍然被提示输入密码,因此如果有人能建议我需要更改什么,我将不胜感激。

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
jay     ALL=(ALL) NOPASSWD: ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

—————————————————————————————————————

jay@laptop:~$ sudo su
[sudo] password for jay: 
root@laptop:/home/jay# visudo

答案1

您需要将其放置jay ALL=(ALL) NOPASSWD: ALL在下方%sudo ALL=(ALL:ALL) ALL,否则后者会妨碍您。

相关内容