65.9K
CodeProject 正在变化。 阅读更多。
Home

Bitbucket Pipelines:修复“ECDSA 主机密钥已更改”

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0投票)

2021 年 7 月 21 日

CPOL

1分钟阅读

viewsIcon

4078

当您将仓库推送到 Bitbucket 时,并且希望 Bitbucket Pipelines 通过 SSH/rsync 将站点部署到您的服务器时,如何修复问题。

我最近将代码推送到 Bitbucket 仓库,并期望 Bitbucket Pipelines 通过 SSH/rsync 将站点部署到我的服务器

但是 rsync 失败并显示了大量的文本:(由于项目是私有的,我已删除了一些细节)

+ rsync -rSlh --stats buildtar/ $user_host:$webpath/myproject
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for mydomain.com has changed,
and the key for the corresponding IP address xx.xx.xx.xx
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:3
ECDSA host key for mydomain.com has changed and you have requested strict checking.
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(228) [sender=v3.13.0_rc2-264-g725ac7fb]

起初这听起来很可怕,但经过一些思考后,我明白了。

这个项目不是部署到云,而是部署到共享主机上的旧式网络空间。
而且它不经常更改,所以上次推送(管道运行成功!)大约是一年前。

我隐约记得,在此期间,我收到了一封来自提供商的维护信息邮件,宣布他们将把我的帐户(以及同一服务器上的其他帐户)迁移到更新、更快的服务器。 这就解释了为什么密钥**和** IP 地址同时发生了变化。

如何修复

域名和密钥的指纹保存在仓库设置中
https://bitbucket.org/YOUR_WORKSPACE/YOUR_REPOSITORY/admin/addon/admin/pipelines/ssh-keys

SSH 密钥下方是这样

在我的主机提供商的管理员 UI 中,我可以看到 SSH 密钥,并且当前指纹也会显示,并且该值确实与 Bitbucket 设置中的值不同。

要“更新”Bitbucket 设置,只需使用右侧的 X 按钮删除整个主机地址,然后再次添加即可。 Bitbucket 将连接到服务器,确定正确的指纹,然后部署将再次工作。

© . All rights reserved.