【发布时间】:2017-11-11 08:41:16
【问题描述】:
我正在尝试使用 ssh 身份验证从 docker 容器内部 git clone 到私有存储库。我遵循了here 提出的解决方案。
为此,我创建了一个本地密钥
ssh-keygen -q -t rsa -N '' -f repo-key
并将公钥添加到github ssh 密钥。然后在我添加的 Dockerfile 中:
RUN chmod 600 repo-key && \
echo "IdentityFile /selenium/repo-key" >> /etc/ssh/ssh_config && \
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
但是当我尝试 git clone 存储库时,我收到了错误消息
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
还有什么我可以检查的吗?
再次解释原因:我希望能够使用固定私钥创建图像,该私钥始终与 github 上的公钥一起使用,因此我可以使用相同的图像,但能够将实际/当前存储库下载到正在运行的容器。该映像配备了正确的密钥,因此它可以访问 github 存储库,并且能够在从同一映像启动包含的内容时下载当前存储库... 该图像用于硒测试,稍后将由脚本(或詹金斯)自动执行,然后我无法“登录”到容器以创建 ssk 密钥对并将公钥上传到 github。整个过程是自动化测试。因此,必须将身份验证构建到图像中。
希望这现在很清楚。
【问题讨论】:
-
您是否尝试过这里讨论的内容:Clone private git repo with dockerfile?
-
哦,谢谢你的链接;我实际上是根据那里提出的解决方案构建我的解决方案...
-
我注意到您的
git clone ssh:// ...命令有一点不同。您是否尝试过那里提到的内容 (git clone git@...)? -
不,因为
git clone ssh...是 - 据我所知 - 通过 ssh 进行身份验证的正确命令......这就是重点...... -
你也可以试试@jpetazzo 建议here 进行调试吗?