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

  • Git switch to master and bring untracked files along
  • Edit last pushed commit's message
  • Git doesn't stage my files any longer, and reports them as both “deleted” and “untracked”. Why is that, and how to avoid it?
  • How to set a git branch to push to a remote with a different branch name and pull from completely different url
  • GitLab requires git@localhost password to push to a repo
  • git add regex example
  • 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

  • What DVCS support Unicode filenames?
  • Git - How to commit a local repository to a subfolder of another local repository?
  • Simulate multiple users/committer's on local system
  • Merging changes from master into all branches using Git?
  • git push authentication fails
  • How to create patch between two tags with multiple commits between them?
  • 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.