3

root@jupiter:/home/jupiter/projects# git clone ssh://git@demo.jupiter.com/diffusion/TD/transcend.git 克隆到 'transcend'...
sudo: 抱歉,需要密码才能运行sudo
致命:无法从远程存储库读取。

我已经按照手册设置了 SSH 。

我也让管道 ping 返回正确的消息:

root@demo:~# echo {} | ssh git@demo.jupiter.com conduit conduit.ping
{"result":"demo.jupiter.com","error_code":null,"error_info":null}

下面是我的 visudo 文件供参考。

Defaults        env_reset

Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"



### User privilege specification
root    ALL=(ALL:ALL) ALL
git     ALL=(ALL:ALL) ALL
git ALL=(root) SETENV: NOPASSWD: /usr/local/bin/git-upload-pack, /usr/local/bin/git-receive-pack

### 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
4

4 回答 4

4

在这个答案中,我发现您应该小心在 sudoers 文件中为用户定义多个条目。您的第二个条目覆盖了 git 用户的第一个条目,并且该第一个条目没有 NOPASSWD: 指令。

我也遇到了同样的问题,并且只在 sudoers 文件中为 git 用户使用以下值解决了这个问题:

git     ALL=(ALL) NOPASSWD: ALL

这表明 git 用户正在尝试将 sudo 用于除 git-upload-pack 和 git-receive-pack 之外的命令。

也可能是您的 PATH 中有多个这些命令,而 git 用户从另一个位置找到这些命令。

于 2014-07-28T20:08:48.520 回答
2

从同一页面,但进一步向下https://secure.phabricator.com/book/phabricator/article/diffusion_hosting/#troubleshooting-ssh

您应该在 phabricator 服务器上测试这些命令(我已将它们从文档中更改为适合您的环境)

$ su git
$ sudo -E -n -u root -- /usr/local/bin/git-upload-pack 

如果一切正常,您将收到

usage: git upload-pack [--strict] [--timeout=<n>] <dir>

你也确定设置了phd.user吗?在您的情况下,这将是“根”

并确保Defaults requiretty在您的 visudo 文件中被注释掉。

希望它对你有用,因为 phabricator 是一个很好的工具。

于 2014-08-30T00:27:21.027 回答
0

在使用https://secure.phabricator.com/book/phabricator/article/diffusion_hosting/上描述的完全 sudoers 配置后,我能够修复错误:

$ vi /etc/sudoers.d/root

root ALL=(root) SETENV: NOPASSWD: ALL

于 2018-10-03T18:09:44.963 回答
0

我刚遇到这个问题,很快就注意到这是因为我在设置 sudoers 文件时没有注意。为了解决这个问题,您可以运行以下命令。

$ which git-upload-pack
$ which git-receive-pack

确保输出的路径与您在 sudoers 文件中列出的路径相同。不需要密码,但只有在这些特定位置运行二进制文件时才需要。

于 2016-03-13T06:39:10.383 回答