Jenkins not able to connect to git repository

got error: Failed to connect to repository : Error performing git command: git ls-remote -h git@mcdasatest07.isd.lacounty.gov:jenkins/ampsoaapplication.git HEAD
when connecting GitLab from Jenkins.

After installed GIT 2.32.0, got error:
Failed to connect to repository: Command “git ls-remote -h [git@mcdasatest07.isd.lacounty.gov]:jenkins/ampsoaapplication.git HEAD” returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

What’s the password for git@mcdasatest07.isd.lacounty.gov supposed to be?

Thank you

Holly

Hi Holly,

This is a host key verification problem. You need to configure a strategy as documented in GitHub - jenkinsci/git-client-plugin at git-client-4.0.0.

Regards,

1 Like

Thank you Allen. Does this document also good for GitLab? I am using GitLab. Thank you

  • Holly

Yes, the documentation applies for GitLab and all other git providers. When the documentation is specific to a git provider, it will list the specific git providers.

Documentation is most easily read from the plugins.jenkins.io/git-client page

Thank you for the reply.
reinstall Git, connecting to Git with Jenkins, got error:
Failed to connect to repository : Error performing git command: git ls-remote -h git@mcdasatest07.isd.lacounty.gov:jenkins/ampsoaapplication.git HEAD

Follow instruction git - “Failed to connect to repository” Error while setting up Github Jenkins Plugin - Stack Overflow Manage Jenkins → Configure System → Git → Git Installations → Path to Git executable .

couldn’t find Git session in Manage Jenkins → Configure System

Do you have the git plugin(s) installed?

Thank you slide.
Yes, I am able to find set up location.
Allan/Mark - plugins.jenkins.io/git-client page , how could I use this document ? what strategy I can use to configure? My current set up by default Known hosts file.
When I run command (git ls-remote -h [git@mcdasatest07.isd.lacounty.gov]:jenkins/ampsoaapplication.git HEAD) from server, it keep asking me the password and not recognized the password.

mcdasatest07:/var/cache>git ls-remote -h [git@mcdasatest07.isd.lacounty.gov]:jenkins/ampsoaapplication.git
git@mcdasatest07.isd.lacounty.gov’s password:
Permission denied, please try again.

You might try this video tutorial from Darin Pope:

The message from command line git indicates that you’re either providing the wrong ssh private key credential or you’re providing a username / password credential instead of providing an ssh private key credential.

The git repository URL git@mcdasatest07.isd.lacounty.gov]:jenkins/ampsoaapplication.git is a URL that tells command line git to authenticate with ssh using an ssh private key. If you’ve not defined an ssh private key credential, then you need to do that. If you’ve defined a username / password credential instead of an ssh private key credential, then you need to change to use https instead of ssh for the git repository URL.

Based on the message from git ls-remote, you don’t need to change the ssh host key verification strategy. It is already working as expected.

Your original post had this message:

If you’re still seeing that message, then you need to adjust your host key verification strategy. The message Host key verification failed means that you do not have a working host key verification strategy because host key verification is failing.

Thanks Mark.

I created a SSH key for another application on my local. Do I need to create another SSH key for this application or I can share the same SSH key with that application.
Is there any meeting discussion in our community? that will be a big help and speed up the issue resolve process.
Appreciate your help.

I created a SSH key for another application on my local. Do I need to create another SSH key for this application or I can share the same SSH key with that application.
Each application need to have it’s own git set up? Please advise.

It is your choice whether you use the same ssh key or a separate ssh key.

The separate ssh key adds some management overhead (need to track it, etc.) but then allows that ssh key to be removed from the account or rotated without breaking any other use of that repository.

Issue resolved. Thank you.

1 Like

Thanks for your feedback @hollychen . :pray: