Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've got an ssh key in ~/.ssh/ 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
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$AbstractBuildExecution.defaultCheckout(
    at jenkins.scm.SCMCheckoutStrategy.checkout(
    at hudson.model.AbstractBuild$
    at hudson.model.Run.execute(
    at hudson.model.ResourceController.execute(
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin /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.

share|improve this question

2 Answers 2

You should have the private key there, not just the public key. If your public key is, your private key is probably named id_rsa.

I assume you copied this public key from some other system (perhaps your local desktop)?

You can either copy the corresponding private key to the jenkins ~/.ssh directory as well, or you can generate a new keypair for your jenkins user and import that public key in bitbucket.

To generate a new ssh keypair:

cd ~/.ssh
ssh-keygen -t rsa

This will generate the following output:

Generating public/private rsa key pair.
Enter file in which to save the key (/home/b/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/jenkins/.ssh/id_rsa.
Your public key has been saved in /home/jenkins/.ssh/
share|improve this answer

The actual problem appeared to be the bitbucket server wasn't in my list of known-hosts. Had to login as the jenkins user and do a git clone again, this added the bitbucket url again to known hosts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.