Des*_*ves 2 permissions command-line sudo password apache2
我一直试图在没有密码的情况下授予www-data
使用sudo service apache2 restart
权限,但无论我尝试什么,都无济于事。我在不同的论坛上阅读了数百篇关于这个问题的帖子,但没有任何帮助。
我知道权限是按顺序添加的,所以特定的命令应该放在列表的末尾。这是我的文件:
#
# 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 secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
# 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
# See sudoers(5) for more information on "#include" directives:
# includedir /etc/sudoers.d
%www-data ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 restart
Run Code Online (Sandbox Code Playgroud)
据我所知,www-data 中的任何人现在都应该能够运行 sudo service apache2 restart 并且不需要密码。它仍然要求输入密码。我试图添加:
%www-data ALL=(ALL) NOPASSWD: ALL
Run Code Online (Sandbox Code Playgroud)
这按预期工作。我可以不给他们所有命令的密码,但不能给一个。当然,那将是非常糟糕的主意。
任何帮助,将不胜感激。这是最新版本的 Ubuntu