【问题标题】:Phabricator git ssh clone fails with password required errorPhabricator git ssh clone 失败,需要密码错误
【发布时间】:2014-06-05 11:56:16
【问题描述】:

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

我已经按照manual 设置了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

【问题讨论】:

    标签: linux git ssh phabricator


    【解决方案1】:

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

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

    git     ALL=(ALL) NOPASSWD: ALL
    

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

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

    【讨论】:

    • 虽然切换到此一种解决方法,但出于安全原因,它并不理想 仔细检查您的路径。如果您使用 git,则需要 gitgit-upload-packgit-receive-pack。使用whereis programname(即whereis git)查找路径。我的正确命令是git ALL=(phabdaemon) SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack。您可以在 Official Docs 上找到需要在此列表中的所有二进制文件的列表
    【解决方案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 是一款出色的工具。

    【讨论】:

      【解决方案3】:

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

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

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

      【讨论】:

        【解决方案4】:

        使用https://secure.phabricator.com/book/phabricator/article/diffusion_hosting/ 中描述的确切 sudoers 配置后,我能够修复错误:

        $ vi /etc/sudoers.d/root

        root ALL=(root) SETENV: NOPASSWD: ALL

        【讨论】:

          猜你喜欢
          • 2012-09-10
          • 2018-08-29
          • 2019-08-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-09-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多