Jenkins Build Using Git with Deploy Key

I added the git plugin to Jenkins. I’ve generated a public key as the jenkins user on the build server. I added this key as a Deploy Key to github. I’ve added the global git properties with the jenkins name and email and the email matches what is at the end of the public key.

When Jenkins tries to pull from the git repository (hosted at Github) I get the following:

  • Is there any difference between `git branch -Dr …` vs. deleting the file directly in refs/remotes/origin?
  • Octopress - source branch suddenly is pushing to master
  • How do I clone an empty bare repository with Ansible git module?
  • Python: catch git error
  • How to separate changes from master into another branch without overwriting history?
  • Undo git rebase to save local changes
  • Started by user anonymous
    Building in workspace /var/lib/jenkins/jobs/Test Deployment/workspace
    Checkout:workspace / /var/lib/jenkins/jobs/Test Deployment/workspace - hudson.remoting.LocalChannel@9ba3afe
    Using strategy: Default
    Cloning the remote Git repository
    Cloning repository origin
    ERROR: Error cloning remote repo 'origin' : Could not clone
    hudson.plugins.git.GitException: Could not clone
        at hudson.plugins.git.GitAPI.clone(
        at hudson.plugins.git.GitSCM$2.invoke(
        at hudson.plugins.git.GitSCM$2.invoke(
        at hudson.FilePath.act(
        at hudson.FilePath.act(
        at hudson.plugins.git.GitSCM.checkout(
        at hudson.model.AbstractProject.checkout(
        at hudson.model.AbstractBuild$AbstractRunner.checkout(
        at hudson.model.AbstractBuild$
        at hudson.model.ResourceController.execute(
    Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin /var/lib/jenkins/jobs/Test Deployment/workspace" returned status code 128:
    stdout: Cloning into /var/lib/jenkins/jobs/Test Deployment/workspace...
    stderr: Host key verification failed.
    fatal: The remote end hung up unexpectedly

    Not sure what the issue is or what I’ve forgotten to do with regards to configuration. Any help is appreciated. Let me know if you need more details.

  • Getting a list of commits along with the commit message and hash in Git
  • Git commit on Windows (Cygwin) is broken.
  • git undo deletes but preserve new work
  • Is it possible to have multiple HEADs within a single git repository?
  • Using Git with Eclipse causing lots of errors
  • invalid credentials - LDAP access error in git community edition
  • 2 Solutions collect form web for “Jenkins Build Using Git with Deploy Key”

    Try adding github to the .ssh/known_hosts file of the jenkins user. If you manually try to clone as the jenkins user, it should prompt you to add as a known host. Once you do that, jenkins should be able to verify the host key when doing builds.

    For the permission denied error, you need to ensure that you are using the key that you have created. To do this, create a file called “config” in your ~/.ssh directory. Populate the config file with the following:

    • HostName
    • User git
    • IdentityFile ~/.ssh/id_rsa
    • IdentitiesOnly yes

    Just ensure that the IdentityFile value points to your key. 🙂

    Verify with the following: ssh -vT

    Git Baby is a git and github fan, let's start git clone.