gpt4 book ai didi

git-clone - 在 Docker 容器中使用 SSH (Windows)

转载 作者:行者123 更新时间:2023-12-02 02:58:31 25 4
gpt4 key购买 nike

microsoft/aspnetcore开始docker 镜像,我能够安装 Chocolatey,然后使用 Chocolatey 安装其他一些软件:

  • 打开-ssh
  • git

  • 现在我想从我们的 Bitbucket 服务器克隆一个 repo:
  • 我将 Bitbucket 服务器添加到 known_hosts文件(甚至从容器 ssh 进入服务器进行仔细检查)
  • 我添加了我的 Bitbucket ssh key ,该 key 已在我的机器上成功使用,并在 Ubuntu 容器中成功使用
  • 我加了一个 config文件在我用户的 .ssh目录告诉 git 使用我的 ssh key

  • 我希望能够使用 git clone ssh://git@<host>/<path to repo> ,但此命令总是失败并出现以下错误:

    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights and the repository exists.



    我使用以下命令使其在 Ubuntu 容器中工作: ssh-agent sh -c 'ssh-add /home/bamboo/.ssh/id_rsa; git clone ssh://git@<host>/<path to repo>' ,但这个命令似乎对 Windows 容器没有任何作用。我从未从 ssh-agent 得到任何反馈,所以我不确定 Open-SSH 是否正常工作,或者 Windows 容器中是否存在 Open-SSH 的已知问题?我确实收到了来自 ssh-add 的反馈说我的 key 已成功添加,但我仍然无法克隆我的 git repo。

    有没有人能够在 Windows 容器中成功地做到这一点?它在我的 Windows 机器上工作,但我没有使用 Open-SSH,我使用的是 Git Bash 工具,它在 Windows 容器中不起作用。这一切都非常令人困惑,因为关于这个主题的所有信息都与 Ubuntu 容器有关,而且这些解决方案都涉及我在 Windows 容器中没有的 Unix 命令。

    我注意到的另一件奇怪的事情是使用 HTTP 进行克隆也不起作用,而是出现以下错误:

    error: failed to execute prompt script (exit code 66) fatal: could not read Password for 'http://(user)@(host)': No error

    最佳答案

    我从 Git for Windows 人员那里得到了一些帮助,他们建议我使用带有 ssh 的详细标志命令,即 ssh -vvvvv <host> .这表明我在用户的 .ssh 中拥有的配置文件目录有一些额外的权限,由错误消息指示:

    debug3: Bad permissions. Try removing permissions for user: S-1-5-11 on file C:\Users\ContainerAdministrator/.ssh/config



    使用 icacls实用程序我能够删除那些允许使用配置文件的权限。

    关于git-clone - 在 Docker 容器中使用 SSH (Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47913876/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com