3

In CentOS 6.5, i would do the following to setup sudo for users -

  1. useradd -G wheel -c "John Smith" jsmith
  2. visudo
  3. uncomment this line - %wheel ALL=(ALL) ALL
  4. usermod -G wheel -a jsmith
  5. restart sshd - /etc/init.d/sshd restart
  6. ssh login as jsmith and type 'sudo bash'

When i try the same thing in CentOS 7, i see the following in /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

Is this procedure not valid for CentOS-7 anymore?

More info -

file /etc/group has this -

wheel:x:10:randomperson,cartman,jsmith

visudo shows this -

## 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

output of sudo -l command -

[jsmith@localhost ~]$ sudo -l
[sudo] password for jsmith:
Sorry, user jsmith may not run sudo on localhost.
[jsmith@localhost ~]$
  • Syntax seems to be correct. Have you tried to add jsmith ALL=(ALL) ALL in visudo? – Glueon Oct 8 '14 at 9:55
  • It works for me (with a new test user). Check the %wheel line is definitely uncommented and check /etc/group to make sure that jsmith is in the wheel row. No need to restart ssh, just log out and back in again. – garethTheRed Oct 8 '14 at 10:04
  • Just doublechecked. /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 – Quest Monger Oct 8 '14 at 10:09
4

You are missing a '%' in the example posted.

It's supposed to be

%wheel   ALL=(ALL)       ALL

not

wheel   ALL=(ALL)       ALL
  • lol, yup works now. thanks. i will take my darwin award and leave. – Quest Monger Oct 8 '14 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.