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
Here is the error :
Failed to connect to repository : Command "git ls-remote -h email@example.com:skurty/ma-carte-augmentee-bo.git HEAD" returned status code 128: stdout: 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 firstname.lastname@example.org, 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 bitbucket.org 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
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 ssh email@example.com
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.
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