在CentOS-7中设置Sudo

在CentOS 6.5中,我会为用户设置sudo

  1. useradd -G wheel -c“John Smith”jsmith
  2. visudo命令
  3. 取消注释此行 – %wheel ALL =(ALL)ALL
  4. usermod -G wheel -a jsmith
  5. 重启sshd – /etc/init.d/sshd restart
  6. sshlogin为jsmith并input“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 ~]$ 

您在发布的示例中缺less“%”。

这应该是

 %wheel ALL=(ALL) ALL 

 wheel ALL=(ALL) ALL