Authentication with Jenkins and Git

I would like to use Jenkins with a repository on Bitbucket. To do this, I created the ssh key with the user jenkinsand the command ssh-keygen -t rsa -C "my_email". I have added the public key to Bitbucket and I can clone the project using git clone ....

But when I set up the project in Jenkins, I put url git@bitbucket.org:my_username/my_repository.git

Here is the error:

Failed to connect to repository : Command "git ls-remote -h git@bitbucket.org: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 git @ bitbucket.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_keysand put the public key in it, but the same problem.

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

Thank you for your help :)

PS: I'm on Debian Squeeze 64 bit

+5
source share
4 answers

, , ssh-. , git jenkins , Credentials.

$ ssh-keygen -p

, .

+3

- , JENKINS GIT

:

JENKINS:

sudo su jenkins
ssh git@bitbucket.org

.

jenkins GIT

+3

id_rsa jenkins?

, /var/lib/jenkins/.ssh, /var/lib/jenkins/.ssh 700, /var/lib/jenkins/.ssh/id_rsa 600

+1

You may need to add your SSH key to your BitBucket account, as well as to Manage_Account → SSH_Keys → Add Key

However, if you still encounter any problems: try the walkthrough:

http://777chmod.wordpress.com/2013/07/28/jenkins/

http://777chmod.wordpress.com/2013/08/01/ssh/

0
source

All Articles