GitLab CI / CD使用SSH /已知主机误差
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要检查在情况下使用的SSH URL。
类似
>会寻找 gitlab.com a>在
〜/.ssh/nownow_host
文件中。请确保在gitlab-runner服务器中首先添加以下内容到
〜/.ssh/nownow_host
:它将跳过SSH中的手动指纹确认。
换句话说,没有更多的“
nownothost:key是未知的
”。请注意,使用 gitlab 15.3 (2022年8月),您将更容易找到这些:
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
: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:
您应该将以下行添加到
/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"
对于仍然遇到此问题的人:在我们的情况下,原因是已知_ -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.