Authentication with Jenkins and Git

I would like to use Jenkins with a repository on Bitbucket. For that, I created a ssh key with the user jenkins and the command ssh-keygen -t rsa -C "my_email". I added the public key on Bitbucket and I can clone a project with git clone ....

But when I configure the project in Jenkins, I put the url

  • Why am I told to 'cd' when updating Homebrew?
  • Git - track multiple remote branches?
  • unresolved deltas with git bundle
  • Git mirroring a repo with all submodules to another repo
  • Push from one repo to another - Git
  • Git notes details
  • Here is the error :

    Failed to connect to repository : Command "git ls-remote -h HEAD" returned status code 128:
    stderr: ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory 
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly

    If I do ssh, I get:

    PTY allocation request failed on channel 0
    conq: logged in as my_username.
    You can use git or hg to connect to Bitbucket. Shell access is disabled.
    Connection to closed.

    I also tried to create the file ~/.ssh/authorized_keys and put in it the public key, but same problem.

    I also restarted jenkins with sudo /etc/init.d/jenkins restart

    Thank you for your help 🙂

    PS : I’m on a Debian Squeeze 64 bits

  • dokku asking for password
  • Run batch scripts on a remote server (windows) from jenkins
  • What is the difference between clone and mkdir->cd->init->remote-add->pull?
  • Run git bash script in Windows 7/64bit
  • Import SVN folder structure to Git Repo without history & users
  • Why do I have to use “git commit -a” rather than just “git commit”?
  • 4 Solutions collect form web for “Authentication with Jenkins and Git”

    The problems comes from the fact that you NEVER logged in with user JENKINS on GIT

    therefore, you should do the following :

    log in JENKINS machine:

    sudo su jenkins

    validate access.

    Now you should be able to perform jenkins build with git

    The only way I found to make it work was removing the passphrase from my ssh keys. I guess the jenkins’ git plugin was having trouble providing the passphrase, even when I set it in the advanced section of the Credentials plugin.

    $ ssh-keygen -p

    Provide the location of your private key, type your current passphrase and leave the new one empty.

    Is the id_rsa or whatever your private key is called, in the jenkins user’s home directory?

    If you installed with a native package, the file should be located in /var/lib/jenkins/.ssh and the permissions for /var/lib/jenkins/.ssh should be 700 while the permissions of /var/lib/jenkins/.ssh/id_rsa should be 600

    You may need to add your SSH Key on your BitBucket account as well in Manage_Account>>SSH_Keys>>Add Key

    However, if you still face any issues: try out the step by step tutorial at:

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