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

  • Gemfile lock merge conflict
  • Invalid active developer path error after upgrading to El Capitan
  • Are there any automated SVN->GIT syncing services?
  • Checkout old commit to temporary directory with git
  • Github, push a new project in place of an old one
  • Git: how to push submodule to a remote repository?
  • 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

  • Apply a command to all commits
  • Assigning issues to yourself on GitHub
  • Permission denied (publickey) copy from remote machine to local
  • Can I put a .gitmodules file in a subdirectory?
  • Why won't git ignore a bin folder in my submodule?
  • Showing git branch in ConEMU
  • 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.