dkish
dkish

Reputation: 339

GitLab runner gets "host key verification failed" for submodules

I am facing the following issue:
I am trying to configure a GitLab CI pipline (shell).
My repository contains two submodules.
Both submodules are on the same GitLab server as the super repository that contains them.
The clone is an SSH clone, I have configured the keys locally, and also added my key to GitLab.
On the machine where the runner is installed, I can clone everything with no issues including the submodules.
However when the runner is trying to clone, it returns with "host key verification failed" but only for the submodules.
I have tried configuring the runner both with its own user and with my user :

sudo gitlab-runner install --user=<user> 

to no effect.
What confuses me the most is that the error is only for the submodles even though they are on the same server as the super repo that contains them, and the super repo can be cloned with no issue (when I turn off the submoudle recursive var in the yml file):

GIT_SUBMODULE_STRATEGY: recursive

But then of course I don't have the submodules.
I will be grateful for any suggestions on what to check or try!

Upvotes: 1

Views: 5956

Answers (2)

the solution that’s so applied to GitLab?

Use the git clone by ssh, I don’t have a good goal that’s so I can up to push that’s changes over a submodule from runner Shell by GitLab CI. The pipeline ever fails and prints this error. ERROR PIPELINE JOB

In the local repo as a project the file config contains that line with the URL, more don’t have login with this about the pipeline. .git/config

Some help or walkthrough of reference to culminate with that challenge in troubleshooting!

This is my code over the file ".gitlab-ci.yml"

variables: TEST_VAR: "Update Git Submoudel in all Etecnic projects."

job1: variables: {} script: - echo "$TEST_VAR"

job2: variables: {} script: - echo "OK" >> exito.txt - git add --all - git commit -m "Update Submodule" - git push origin HEAD:master Expand snippet Versions:

GitLab:

gitlab-ce is already the newest version (15.7.0-ce.0).

Runner:

Version: 15.6.1

Git revision: 7178588d

Git branch: 15-5-stable

GO version: go1.18.7

Built: 2022-11-11T09:45:25+0000

OS/Arch: linux/amd64

Thanks so much for your attention.

Upvotes: -2

LeGEC
LeGEC

Reputation: 51850

"host key verification failed" is about the machine key (the ones listed in ~/.ssh/known_hosts), not your gitlab key.

For example : if the initial git clone is not run with the same user as the one which updates the submodules, then they do not have the same ~/.ssh/known_hosts file, and the ssh command could work for the first user without error, while failing for the second.


The clean fix would be : copy the host key you know to be correct to the expected known_host file.

see for example ssh use known_hosts other than $HOME/.ssh/known_hosts :

# use a 'known_hosts' file with the host key of your git server
GIT_SSH_COMMAND=`ssh -o UserKnownHostsFile=<some provisioned known_hosts file>`

The workaround almost everybody uses is : turn HostKey verification off.

# for example : set the GIT_SSH_COMMAND environment variable
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no'

Upvotes: 6

Related Questions