我希望允许git以用户'www-data‘的身份运行'git拉’。据我所知
git ALL=(www-data) git pullin /etc/sudoers应该能做到。
遗憾的是,我在这一行中得到了一个语法错误,并且在'www-data‘中的"-“之后得到了突出显示。
无法在/etc/sudoers用户名中找到有关禁用'-‘的信息。有小费吗?
发布于 2011-05-13 11:56:18
您需要为“git”命令使用完整的路径名,下面的行在visudo中不会产生语法错误,并且工作正常。
git ALL = (www-data) /usr/bin/git pull
发布于 2012-06-21 17:38:39
请注意,我使用的是git用户名,所以,如果您正在使用gitosis或任何其他用户名,只需填写您的!
在控制台中,使用root用户执行以下命令:
visudo"vi“编辑器将被打开。增加以下几行:
Defaults:git !authenticate
git ALL=(www-data) ALL因此,文件(通过调用“visudo”在"vi“编辑器中打开)应该如下所示:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults:git !authenticate
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
git ALL=(www-data) ALL
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d然后按CTRL+O保存文件,然后按Enter键接受文件名( bla ),然后按CTRL+X关闭"vi“编辑器。
瞧!现在git用户可以以www-data用户的身份执行命令:
sudo -u www-data git pull origin masterhttps://serverfault.com/questions/269359
复制相似问题