使用站点部署时如何摆脱此提示?“你确定要继续连接吗?”
我知道这个问题已被多次询问(链接、链接),但推荐的解决方案对我不起作用,我将解释原因。
哦,我在这里发布了几乎完全相同的问题
解决方案是:
# Run this manually:
ssh -o UserKnownHostsFile=foo javadoc.foo.com
# Take that file and put it in your private DAV share, and then
ssh -o UserKnownHostsFile=/private/<account>/known_hosts javadoc.foo.com
它在 99% 的时间里都运行良好,但是使用这个解决方案,我们每隔一段时间就会在日志中一遍又一遍地看到以下文本:
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Please contact your system administrator.
Add correct host key in known_hosts to get rid of this message.
Do you want to delete the old key and insert the new key? (yes/no)
所以,回到我的问题:简而言之,问题是这样的:当我运行 mvn site-deploy 时,它在 Jenkins 中陷入了无限循环:
The authenticity of host 'javadoc.foo.com' can't be established.
RSA key fingerprint is 3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Are you sure you want to continue connecting? (yes/no)
The authenticity of host 'javadoc.foo.com' can't be established.
RSA key fingerprint is 3d:69:41:8a:ec:d1:4c:d9:75:ef:7d:71:b7:7d:61:d0.
Are you sure you want to continue connecting? (yes/no)
发生这种情况的机器是 CloudBees 机器,所以它不是我们拥有的机器。换句话说,每次我们进行构建时,都会为我们提供一台全新的机器。
我们的 settings.xml 有类似的东西:
<server>
<id>javadoc.foo.com</id>
<username>username</username>
<password>password</password>
</server>
如果它是我们拥有和控制的机器,我们可以在那里手动 ssh 并运行 ssh 命令一次,这样就可以解决这个问题,但就像我说的那样,这些机器是动态配置给我们的。
由于我们使用的是 maven 3 而不是 maven 2,因此我们无法将以下内容添加到 settings.xml 的服务器部分:
<configuration>
<knownHostsProvider implementation="org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider">
<hostKeyChecking>no</hostKeyChecking>
</knownHostsProvider>
</configuration>
有没有办法:
- 以编程方式回答是(这不是自由风格的 Jenkins 工作;这是 Maven 项目。)
- 站点部署的替代方案(pom.xml 中的蚂蚁代码?)
- 如果这个问题没有得到回答,则站点部署失败,这样 Jenkins 构建就不会用一遍又一遍地重复这个问题来填充磁盘空间。
- 告诉 site-deploy 插件将 stricthostkeychecking 设置为“no”
我想避免任何可能调整 ssh 设置的预构建步骤;我更愿意调整 settings.xml、pom.xml 或 maven 选项。
尽管如此,我愿意接受任何建议。