【问题标题】:broken dockerfile : github deploy key no longer copied correctly损坏的 dockerfile:github 部署密钥不再正确复制
【发布时间】:2016-09-05 04:06:51
【问题描述】:

以下 sn-p 一个月前运行良好(我上次运行容器时)。今天不行。为什么?

RUN mkdir /root/.ssh && \
    mv /root/deployment_key /root/.ssh/id_rsa &&  cat /root/.ssh/id_rsa && \
    chmod 600 /root/.ssh && \
    chmod 600 /root/.ssh/id_rsa && \
    ssh-keyscan github.com,$(getent hosts github.com | awk '{ print $1 }') > ~/.ssh/known_hosts

当我cat ~/.ssh/known_hosts 时,公钥只有预期长度的一半左右。 /root/.ssh/id_rsa 中的私钥是正确的。

下一行(私人回购的git clone)失败并显示

Permission denied (publickey).
fatal: The remote end hung up unexpectedly
The command '/bin/sh -c git clone ssh://FOO@github.com/FOO/PRIVAT_REPO.git' returned a non-zero code: 128

我在 OSX 上运行 docker 版本 1.12.1-rc1-beta23(内部版本:11375),但在 Windows 10 上也失败了。

【问题讨论】:

    标签: git ssh docker


    【解决方案1】:
    mv /root/deployment_key /root/.ssh/id_rsa 
    

    这意味着您的Dockerfile 包含一个ADDCOPY 命令,该命令首先填充/root/deployment_keyRUN mv 命令之前。

    尝试通过以下方式从现有的 Dockerfile 制作另一个图像:

    • 将新图像的Dockerfile 修改为RUN echo /root/deployment_key/id_rsa.pub 并查看它是否存在,以及预期的内容和内容长度,
    • 拆分您的 RUN 命令以隔离 RUN mv 部分并检查其内容,然后再继续执行该 RUN 命令的其余部分。

    【讨论】:

    • @gvoysey 私人?我在回答 id_rsa.pub:public 密钥。
    • 啊。不,正如我上面所说,公钥没有被正确复制。
    • @gvoysey 确切地说:这就是我在答案中提到的:检查公钥是否在/root/deployment_key 中正确复制(在 mv 之前)。如果没有,你需要先解决这个问题。
    • 再一次:那是私钥。是的,它被正确复制了。问题在于ssh-keyscan github.com,$(getent hosts github.com | awk '{ print $1 }') > ~/.ssh/known_hosts,因为 known_hosts 在中途被截断。
    猜你喜欢
    • 2017-11-05
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 2011-09-29
    • 2021-06-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多