0

On a RHEL server I would like to let a user run a command as root without a password:

# uname -a
Linux foo.com 2.6.32-220.38.1.el6.x86_64 #1 SMP Wed May 15 08:34:56 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/issue
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel \r on an \m

# visudo
User_Alias FOOEMPLOYEES = someuser
Cmnd_Alias FOOCOMMANDS = /root/bin/fix-permissions
FOOEMPLOYEES   ALL = NOPASSWD: FOOCOMMANDS

For some reason, the system is still asking the user for his password:

$ alias
alias fix-permissions='/root/bin/fix-permissions'

$ fix-permissions 
-bash: /root/bin/fix-permissions: Permission denied

$ sudo fix-permissions 
[sudo] password for someuser:

Why might the sudo configuration not work? Did I configure it wrong? I copied the configuration from this guide.

  • Do the command start without sudo with full path /root/bin/fix-permissions? And the last string shoul be ` FOOEMPLOYEES ALL = (ALL) NOPASSWD: FOOCOMMANDS` – Costas Oct 26 '14 at 10:14
  • From the man sudoers > The basic structure of a user specification is “who where = (as_whom) what” – Costas Oct 26 '14 at 10:28
  • Thank you! I've updated the visudo line to FOOEMPLOYEES ALL = (ALL) NOPASSWD: FOOCOMMANDS. Running /root/bin/fix-permissions still comments that permission is denied, but running sudo /root/bin/fix-permissions actually works. – dotancohen Oct 26 '14 at 11:08
3

The last string should be

FOOEMPLOYEES ALL = (ALL) NOPASSWD: FOOCOMMANDS

From the man sudoers

The basic structure of a user specification is “who where = (as_whom) what”

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.