Having a problem with sudo. As the user forge
I want to be able to run sudo service php5-fpm reload
without having to type a password. I've tried all of the variants below.
forge ALL=NOPASSWD: /usr/bin/service php5-fpm reload
forge ALL=NOPASSWD: /usr/bin/service
forge ALL=(ALL:ALL) NOPASSWD: /usr/bin/service
forge ALL=(ALL:ALL) NOPASSWD: /usr/bin/service php5-fpm reload
But it keeps prompting me for a password. Tried loggin in and out.
# tail /var/log/auth.log
Sep 16 09:28:19 apps sudo: pam_unix(sudo:auth): conversation failed
Sep 16 09:28:19 apps sudo: pam_unix(sudo:auth): auth could not identify password for [forge]
This is the whole file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig
# User privilege specification
root ALL=(ALL:ALL) ALL
#forge ALL=NOPASSWD: /usr/bin/service
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
Using Ubuntu 14.04.1 LTS
$ which service
/usr/sbin/service
The problem:
$ sudo service
[sudo] password for forge:
This is what worked.
visudo:
# Cmnd alias specification
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig/, /usr/bin/service, /usr/sbin/service
/etc/sudoers.d/forge
:
forge ALL = (ALL) NOPASSWD: SERVICES
Tried to move the content of the forge
file into visudo
, but that didn't work.
You're giving the wrong
PATH
to the binary. Thewhich
output shows that it's/usr/sbin/service
, but you keep specifying/usr/bin/service
in yoursudoers
entries.Try
Try following:
/etc/sudoers
:/etc/sudoers.d/forge
:test
Adjust CORRECT path to your
service
if needed, this may vary depends on your distribution, to find correct path run following: