2

I've got an ssh key in ~/.ssh/id_rsa.pub when I login as the jenkins user.

I've imported this into bitbucket correctly and it has accepted the key.

When I try to do a git clone (to the correct URL) I still get....

Building in workspace /var/lib/jenkins/jobs/Google adwords/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Google adwords/workspace - hudson.remoting.LocalChannel@2c473996
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone git@bitbucket.org:DAVID99WORLD/assessme.git
hudson.plugins.git.GitException: Could not clone git@bitbucket.org:DAVID99WORLD/assessme.git
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:268)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)
    at hudson.FilePath.act(FilePath.java:842)
    at hudson.FilePath.act(FilePath.java:824)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
    at hudson.model.Run.execute(Run.java:1502)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@bitbucket.org:DAVID99WORLD/assessme.git /var/lib/jenkins/jobs/Google adwords/workspace" returned status code 128:
stdout: Cloning into '/var/lib/jenkins/jobs/Google adwords/workspace'...

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

Does anyone know of a reason why this would occur? According to the documentation I've read ~/.ssh is the correct directory as the jenkins user for this file to exist.

EDIT : My jenkins user does not have a known_hosts file in ~/.ssh but my root level ones do - should it? I can do a clone with my jenkins user just fine and it doesn't mention the host at all as jenkins user.

David
  • 19,577
  • 28
  • 108
  • 128

1 Answers1

4

It is probably not related to the known_hosts file. I think, you have to check that Jenkins is able to read your public SSH key. Therefore, you might want to check that:

  • home defined for Jenkins user in /etc/passwd matches ~/.ssh
  • Jenkins user has access to his home directory (so at least --x--x--x on all dirs above)
  • Jenkins user has access to the id_rsa.pub file
  • Jenkins is actually running with Jenkins user and not e.g. tomcat user

Also, what happens if you remove your current id_rsa.pub file? Does it complain of not finding a public key to use?

Sebi
  • 8,323
  • 6
  • 48
  • 76
  • can you write the macosx commands we need to run to perform this operation? I've the exact same problem. I'm really getting crazy with it http://stackoverflow.com/questions/13267964/configure-jenkins-to-connect-to-bitbucket – Claus Nov 07 '12 at 17:34
  • @Claus It is very hard to do that as it heavily depends on the server configuration. – Sebi Nov 07 '12 at 20:12