由于 git ssh 密钥,从新服务器进行捆绑安装错误

bundle install from a new server errors due to git ssh key

我正在通过 chef 安装新服务器 并将 ssh 私钥和 public 密钥复制到其中。

创建后,我通过 jenkins 和 运行ning bundle install 将应用程序部署到它上面,由于

而失败
Host key verification failed.
fatal: The remote end hung up unexpectedly

如果我 ssh 进入服务器并 运行 自己执行 bundle install 命令,我会收到

提示
The authenticity of host 'bitbucket.org (104.192.143.1)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)?

github

相同
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes

我按是,捆绑完成。最重要的是,如果我现在再次 运行 jenkins 作业,则捆绑包会成功完成。

任何想法,如何通过詹金斯自动批准这些远程服务器的真实性?

批准的信息保存在您的 ~/.ssh/known_hosts 中,因此您可以将其与您的密钥一起复制,这样您就知道哪些密钥已获得批准。

或者您可以使用 ssh-keyscan 检索信息并将结果附加到服务器的 known_hosts,但是请注意,如果您自动这样做,您将面临接受 MITM 机器的风险(因为您不看不到已批准的内容)。

您终于可以禁用主机检查 ssh -o StrictHostKeyChecking=no github.com,但这对自动化同样不利 ssh-keyscan。