21

When I do build in Jenkins, it fails with this error. Any idea?

ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:test/test.git
ERROR: Cause: Error performing command: git clone --progress -o origin 

git@github.com:test/test.git /var/lib/jenkins/jobs/test/workspace
Command "git clone --progress -o origin git@github.com:test/test.git 
/var/lib/jenkins/jobs/test/workspace" returned status code 128: Initialized empty Git 
repository in /var/lib/jenkins/jobs/test/workspace/.git/

No protocol specified

(ssh-askpass:801): Gtk-WARNING **: cannot open display: :0.0
Host key verification failed.
fatal: The remote end hung up unexpectedly
Stefan Crain
  • 2,010
  • 3
  • 21
  • 22
Sam
  • 211
  • 1
  • 2
  • 3
  • I answer this a similar question, you can see the answer in the link below:
    [jenkins & GitHub](http://stackoverflow.com/questions/6515039/jenkins-git-permission-denied-publickey/8143432#8143432)

    Thanks you,
    gustavo
    – iDeasTouch Nov 15 '11 at 21:44

5 Answers5

23

You need to copy your private ssh key into the .ssh folder beneath Jenkins. Something like (on Ubuntu Lucid): /var/lib/jenkins/.ssh

Kara
  • 6,115
  • 16
  • 50
  • 57
Hedgehog
  • 5,487
  • 4
  • 36
  • 43
  • 4
    You'll need to chown the files you copy into /var/lib/jenkins. In addition, you may want to copy your .gitconfig file into /var/lib/jenkins – jwriteclub Oct 24 '11 at 08:26
  • 20
    Better yet, don't put your private keys in other places than your own home directory. Create a new set of keys for jenkins, and give the jenkins public key to github. – Bjarke Freund-Hansen Nov 09 '11 at 13:13
15

Host key verification failed. - make sure your SSH keys are setup properly.

http://help.github.com/linux-set-up-git/

After you are done with that,

ssh git@github.com

should give you a welcome message ( which also says no shell access ) from GitHub

manojlds
  • 290,304
  • 63
  • 469
  • 417
7

Had the same problem, even though the ssh-keys were correctly set up.

The issue was that on the first connection attempt, the git-server needed to be added to the known hosts file

/.ssh/known_hosts

. Git prompts you for this on first connect-attempt: Are you sure you want to continue connecting (yes/no)?, but Jenkins did not nor can it pass on the prompt, so it failed silently.

We solved it by walking to our ops-guy, bringing him a nice cup of espresso, and had him do a random git-checkout, where he answered yes to said prompt :) After that, checkouts through Jenkins worked as expected.

Found the clue here: http://www.ipsure.com/blog/2010/ssh-public-key-w-rsa-authentication-and-ssh-tunneling-part-1/

Frederik Struck-Schøning
  • 12,981
  • 8
  • 59
  • 68
2

If you still have the Host key verification failed problem I answered a similar problem with a step by step solution here :

Jenkins & Github not using SSH Key

Community
  • 1
  • 1
vdaubry
  • 11,369
  • 7
  • 54
  • 76
0

Actually, I ended up with simply using https instead of ssh to clone the repository from GitHub to Jenkins.

So instead of: git@github.com:[user]/[repository].git I used: https://github.com/[user]/[repository].git as the repository URL.

Ondrej Machulda
  • 998
  • 1
  • 12
  • 24