Host key verification failed using gitlab and jenkins

18,109

If you make the repo you are trying to connect to public in Gitlab (Settings -> Edit Project -> Public mode) you should be able to connect using http (but only http).

If the repo is not public you will need to install an SSH key on Jenkins that has permissions to access the repo. My understanding is that the Jenkins git plugin does not currently use the SSH credentials already stored in Jenkins so you will need to install the key on the master and slaves that will run this build. How you do this will depend on your OS but I find it easiest to use an SSH config file on Linux.

Share:
18,109
Keith Rumjahn
Author by

Keith Rumjahn

Updated on June 16, 2022

Comments

  • Keith Rumjahn
    Keith Rumjahn about 2 years

    I get Host key verification failed error whenever I try to put my GITLAB git address into Jenkins.

    I've tried: - using multiple different SSH paths. Including removing : and replacing /. Used http - I've ssh and tried to run the command in the terminal, when prompted to say y/n I pressed Y. - It works with Github. - I've tried going to my jenkins/.ssh/ida_pub and adding my keys.

    Failed to connect to repository : Command "/usr/local/git/bin/git ls-remote -h git@:/.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.

  • Keith Rumjahn
    Keith Rumjahn almost 11 years
    Thank you so much. Yes, I need to add my SSH keys and I followed this guide to fix it.
  • harperville
    harperville over 8 years
    @keith-rumjahn, your link is broken, try this one instead: gist.github.com/victorborda/2871029
  • IceFire
    IceFire over 4 years
    @harperville both are dead
  • harperville
    harperville over 4 years
    What it comes down to is using the same public key from my SSH public/private key pair on multiple Jenkins slaves (as well as the master). Add the key to your GitLab and deploy that public (.pub) and private to your servers that need to access the repo.