在 CentOS 6.5 中,我会执行以下操作来为用户设置 sudo -
- useradd -G wheel -c“约翰史密斯”jsmith
- 视觉
- 取消注释这一行 - %wheel ALL=(ALL) ALL
- usermod -G 轮子 -a jsmith
- 重启 sshd - /etc/init.d/sshd 重启
- ssh 以 jsmith 身份登录并输入“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 ~]$