在 CentOS 6.5 中,我将执行以下操作来为用户设置 sudo -
- useradd -G wheel -c “约翰·史密斯” jsmith
- 维苏多
- 取消注释此行 - %wheel ALL=(ALL) ALL
- usermod -G wheel -a jsmith
- 重新启动 sshd — /etc/init.d/sshd restart
- 以 jsmith 身份 ssh 登录并输入“sudo bash”
当我在 CentOS 7 中尝试同样的事情时,我在 /var/log/secure 中看到以下内容 -
Oct 8 05:20:00 localhost sudo: jsmith : user NOT in sudoers ; TTY=pts/1 ; PWD=/home/jsmith ; USER=root ; COMMAND=/bin/bash
此过程对 CentOS-7 不再有效吗?
更多信息 -
文件 /etc/group 有这个 -
wheel:x:10:randomperson,cartman,jsmith
visudo 显示:
## Allow root to run any commands anywhere
root ALL=(ALL) 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
sudo -l 命令的输出 -
[jsmith@localhost ~]$ sudo -l
[sudo] password for jsmith:
Sorry, user jsmith may not run sudo on localhost.
[jsmith@localhost ~]$
答案1
您在发布的示例中缺少“%”。
应该是
%wheel ALL=(ALL) ALL
不是
wheel ALL=(ALL) ALL