【发布时间】:2018-07-30 01:12:59
【问题描述】:
我正在尝试在构建过程中向 ssh-agent(docker 映像)添加本地私钥。
问题
我已经运行 eval$(ssh-agent -s) 并且一旦 docker 运行 ssh-add /etc/ssh/id_rsa 我收到以下错误:
Could not open a connection to your authentication agent.
目标: 我需要在 NPM 安装过程中克隆一个私有 git 存储库。这个本地密钥将允许我对私人仓库进行身份验证。
==== 输出片段 ====
Step 8/16 : RUN eval $(ssh-agent -s)
---> Running in 195ffeb1f84f
Agent pid 8
---> 0fcbc89d362f
Removing intermediate container 195ffeb1f84f
Step 9/16 : RUN ssh-add /etc/ssh/id_rsa
---> Running in ae99039e1fba
Could not open a connection to your authentication agent.
The command '/bin/sh -c ssh-add /etc/ssh/id_rsa' returned a non-zero code: 2
【问题讨论】:
-
您在步骤 8 中运行的代理在您进入步骤 9 时已失效。您需要或一次性执行所有步骤才能使其正常工作。
RUN eval $(ssh-agent -s) && ssh-add /etc/ssh/id_rsa && git checkout ..... -
我真的只是想通了。非常感谢!