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.
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:
Also, what happens if you remove your current id_rsa.pub file? Does it complain of not finding a public key to use?