CentOS7 中的 visudo 更改不被接受

CentOS7 中的 visudo 更改不被接受

这是我的 sudoers 文件。我使用 sudo visudo 访问它。我已添加此新用户 '用户'然后注销/登录回系统,但该用户仍然需要密码才能运行 sudo 命令。

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
user    ALL=(ALL)       NOPASSWD: ALL

## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d

答案1

由于您的 visudo 文件的构造和顺序,并且您确认用户是“wheel”组的成员 - visudo 文件应用最后适用的权限。

因此您将用户设置为没有密码。

但是 wheel 组(用户是其成员)需要密码。此设置有效,因为这是在告诉用户不使用密码之后设置的。

如果你希望用户无需密码即可运行 sudo:

  • 放在user ALL=(ALL) NOPASSWD: ALL此线以下%wheel ALL=(ALL) ALL
  • 从“wheel”组中删除用户。

相关内容