sudo 有问题。作为用户forge
,我希望sudo service php5-fpm reload
无需输入密码即可运行。我已经尝试了以下所有变体。
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
但它一直提示我输入密码。尝试登录和退出。
# 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 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
使用 Ubuntu 14.04.1 LTS
$ which service
/usr/sbin/service
问题:
$ sudo service
[sudo] password for forge:
这是有效的。
视觉:
# 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
试图将forge
文件的内容移动到中visudo
,但没有奏效。
你给
PATH
二进制错误。输出显示which
它是/usr/sbin/service
,但您继续/usr/bin/service
在sudoers
条目中指定。尝试
尝试以下操作:
/etc/sudoers
:/etc/sudoers.d/forge
:测试
如果需要,将正确的路径调整为您的
service
,这可能会因您的发行版而异,以找到正确的路径运行如下: