Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins & Github not using SSH Key

Tags:

github

jenkins

I've setup Jenkins to pull from a private repository on Github for a specific job. It appears the SSH key is not being used by Jenkins, despite the fact that I have generated a private/public key and added it to github as a deploy key.

When I git clone from the Jenkins user, I'm prompted for a username and password. Why isn't it using my ~/.ssh/id_rsa.pub key?

Thanks

like image 804
Kyle Avatar asked Jun 16 '12 02:06

Kyle


2 Answers

Which url are you using? It sounds like you are using the https one instead of the ssh one.

At the top of your projects github page, there are buttons for three urls, HTTP, SSH, Git read-only. You want the SSH one.

like image 150
recampbell Avatar answered Sep 24 '22 16:09

recampbell


Just had the same problem, here is what you can do :

1) Login as jenkins users

sudo su jenkins

2) Generate keys for the jenkins user :

ssh-keygen -t rsa

3) Enter the id_rsa.pub as deploy key in the admin section of your repo on GitHub

Or even better :

  • Create a Github user for jenkins
  • Add the ssh key in the user profile information
  • Add the jenkins guthub user as a collaborator on your project

Hope this helps, Vincent

like image 38
vdaubry Avatar answered Sep 23 '22 16:09

vdaubry