GitLab CI / CD使用SSH /已知主机误差

发布于 2025-02-06 15:08:04 字数 451 浏览 4 评论 0原文

我正在尝试使用gitlab ci/cd自动部署我的代码,在按下特定的分支(在我的情况“登台”分支)之后,

推开“登台”分支后,我在Gitlab UI中看到了以下错误

Running with gitlab-runner 15.0.0 (xxxxxx)
  on deploy xxxxxx
Preparing the "ssh" executor
00:36
Using SSH executor...
ERROR: Preparation failed: ssh command Connect() error: ssh Dial() error: ssh: handshake failed: knownhosts: key is unknown

。可以从我的VM和Gitlab-runner中看到GitLab成功注册。

我还创建了SSH键,并将其添加到GitLab-runner安装步骤中。

I'm trying to use gitlab CI/CD to auto deploy my code, after push on an specific branch (in my case 'staging' branch)

after push on 'staging' branch I see following error on jobs section in gitlab UI:

Running with gitlab-runner 15.0.0 (xxxxxx)
  on deploy xxxxxx
Preparing the "ssh" executor
00:36
Using SSH executor...
ERROR: Preparation failed: ssh command Connect() error: ssh Dial() error: ssh: handshake failed: knownhosts: key is unknown

I can see gitlab from my VM and gitlab-runner registered successfully before.

I've also created ssh key and add it to gitlab-runner installation steps.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

本王不退位尔等都是臣 2025-02-13 15:08:04

您需要检查在情况下使用的SSH URL。

类似>会寻找 gitlab.com a>在〜/.ssh/nownow_host文件中。

请确保在gitlab-runner服务器中首先添加以下内容到〜/.ssh/nownow_host

gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf
gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9
gitlab.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFSMqzJeV9rUzU4kWitGjeR4PWSa29SPqJ1fVkhtj3Hw9xjLVXVYrU9QlYWrOLXBpQ6KWjbjTDTdDkoohFzgbEY=

它将跳过SSH中的手动指纹确认。
换句话说,没有更多的“ nownothost:key是未知的”。


请注意,使用 gitlab 15.3 (2022年8月),您将更容易找到这些:

SSH指纹的新链接

由于SSH配置页面和文档中的新链接,您的Gitlab SSH指纹现在更容易找到。

谢谢 andreas deicha 您的贡献!

“

evarese

You need to check what SSH URL is used in your case.

Something like [email protected]:me/myProject would look for gitlab.com SSH host keys fingerprints in an ~/.ssh/known_hosts file.

Make sure to add first in gitlab-runner server the following to ~/.ssh/known_hosts:

gitlab.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf
gitlab.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9
gitlab.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFSMqzJeV9rUzU4kWitGjeR4PWSa29SPqJ1fVkhtj3Hw9xjLVXVYrU9QlYWrOLXBpQ6KWjbjTDTdDkoohFzgbEY=

That will skip manual fingerprint confirmation in SSH.
In other words, no more "knownhosts: key is unknown".


Note that with GitLab 15.3 (August 2022), you will have an easier time finding those:

New links to SSH fingerprints

Your GitLab SSH fingerprints are now easier to find, thanks to new links on the SSH configuration page and in the documentation.

Thank you Andreas Deicha for your contribution!

https://about.gitlab.com/images/15_3/manage-ssh-fingerprint.png -- New links to SSH fingerprints

See Documentation and Issue.

ぺ禁宫浮华殁 2025-02-13 15:08:04

您应该将以下行添加到/etc/gitlab-runner/config.toml下方[[[Runner.ssh]]与您的SSH Runner相对应的部分:

nown> nown> nown_hosts_file = “/home/< gitlab-runner-user>/。ssh.nown_hosts”

you should add below line to /etc/gitlab-runner/config.toml under [[runner.ssh]] section corresponding to your ssh runner:

known_hosts_file = "/home/<gitlab-runner-user>/.ssh.known_hosts"

忆梦 2025-02-13 15:08:04

对于仍然遇到此问题的人:在我们的情况下,原因是已知_ -HOST文件中的主机名与TOML文件中的主机名之间的区别。他们必须既具有完全合格的或既有不合格的。

For people who still encounter this issue: in our case the cause was a difference between the host name in the known_host file and the one in the toml file. They must be both fully qualified or both non qualified.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文