cant checkout external git repo in jenkins

I have jenkins on openshift. I can do following and it works.

[jenkins-<USER> data]\> ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /var/lib/openshift/<NUMBERED DIRECTORY>/app-root/data/.ssh/jenkins_id_rsa
Warning: Permanently added ',' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi <USER>! You've successfully authenticated, but GitHub does not provide shell access.
          Connection to closed.

So it does connect to github…even I cloned it worked from shell.

But when I try to add repo to a jenkins job it gives following error. Its a private repo.

Failed to connect to repository : Command "git ls-remote -h<USER>/test.git HEAD" returned status code 128:
stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly

  • Why can I not clone repository from Github using Cygwin SSH on Windows 7?
  • How can I set read only access to ssh git server?
  • Why git clone git:// is not working
  • BitBucket: Host key authentication failed
  • Netbeans, git, cant clone repository
  • gitlab with two ssh keys not connecting (config updated)
  • git clone on windows
  • Git ssh forward-agent not being used on remote server
  • One Solution collect form web for “cant checkout external git repo in jenkins”

    Jenkins is probably running as jenkins and you accepted the host key for <USER> you can confirm this by adding the command whoami to your build steps and confirm the user in jenkins is different from the one in the shell.

    One solution is to login as jenkins and accept the the key for github.

    Another is to copy the line from ~/.ssh/known_hosts of github and copy it to the known_hosts in the jenkins folder ~jenkins/.ssh/known_hosts.

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