jenkins/hudson can't connect to github repo

I am on Ec2 with the base amazon ami linux- I have installed jenkins but when I go to pull the repo from github I am given the following error:

Building in workspace /var/lib/jenkins/workspace/build social
Checkout:build social / /var/lib/jenkins/workspace/build social - hudson.remoting.LocalChannel@5c7b21b
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/workspace/build social" returned status code 128:
stdout: Cloning into /var/lib/jenkins/workspace/build social...

stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly

I have generated a key for the current user who installed jenkins and have managed to clone the repo using the git command line but jenkins can not.

  • How did these git commits get duplicated into the wrong branch?
  • What's a <pathspec> in the git command?
  • In Git, how do you apply a commit of bug fix to the other newer branches?
  • Trying to get the git commit ID in grunt
  • How to add symlinks to git repository on Windows?
  • Customize CSH prompt for Git repo
  • I have copied the ~/.ssh files into /var/lib/jenkins/.ssh

    I have added github to the known hosts and I have run out of solutions to try. Anyone know where I am going wrong? Is there a way to get jenkins to show the public key it’s using and I can debug if it’s using the correct one?

    I removed the name of the repo because its a private repo

  • Why do I have problems pushing new branches to my Git repository?
  • What does it mean when git says a file “needs update”?
  • gerrit: push: no changes between prior commit and new commit. Not able to pull changes
  • Adding a Git subrepository to Mercurial
  • How to revert a file to a previous version without overwriting current changes?
  • creating new maven managed git controled project using intellij
  • 6 Solutions collect form web for “jenkins/hudson can't connect to github repo”

    The error seems to be: host key verification failed.

    You should log into your Jenkins host as the Jenkins user and run:


    Then answer yes to the prompt about the host key. This only needs to be done once.

    Alternatively you could add “StrictHostKeyChecking no” to ~jenkins/.ssh/config.

    I’m using a single jenkins machine to check out multiple github repositories and had similar problems when setting it up. What I ended up doing was configuring an SSH config file for jenkins so that SSH would automatically know which id file to associate with each repository.


    Host github-ABC
      User git
      IdentityFile /var/lib/jenkins/.ssh/id_rsa_ABC

    In the Jenkins project config under source code management, I used this as the repository name:


    Finally, I use the SSH public key as a deploy key in the github repository.

    He following helped me:

    Login under Jenkins

    sudo su jenkins

    Copy your github key to Jenkins .ssh folder

    cp ~/.ssh/id_rsa_github* /var/lib/jenkins/.ssh/

    Raname the keys

    mv id_rsa_github id_rsa

    1) Switch User into your jenkins account

    su jenkins

    2) Create the key without a passphrase

    3) ssh

    That worked perfectly for me.

    You may need to create a password for the jenkins account, if so use sudo passwd jenkins

    If you log in as jenkins you can do

    ssh -i ~/.ssh/id_rsa

    where ~/.ssh/id_rsa is the path/to/your/ssh/key and it will prompt for the password and add to the known_hosts file

    You need to add the ssh key of jenkins to you github user.

    Generate ssh key

    Go to:

    Github->Settings(Top right)->SSH Keys(Left Pane)->Add SSH Key

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