Search code examples
djangoamazon-web-servicesgitjenkinsprivate-repository

Jenkins unable to connect to github private repo


I'm running Jenkins on an AWS Amazon Linux 2 EC2 instance.

I have setup the instance and have jenkins running as well. I'm currently trying to add the job to deploy my private repo (Django web app) to the EC2 instance.

I have used ssh-keygen and placed the public key in my github SSH keys and the private key in my credentials within Jenkins.

I have been researching and almost every source does exactly what I've been doing.

Any ideas on how to resolve this? I know that github changed some of their login capabilities in the last few years, so i'm not sure if these posts are outdated.

This is the error I'm getting

enter image description here

You can see my credentials config below:

enter image description here

And my github ssh key here:

enter image description here

I have verified that I am able to authenticate from my EC2 instance via ssh -T git@github.com (Jenkins still not authenticating):

enter image description here

I have also tried using a username/password authorization (private key as password), but that gives the exact same error:

enter image description here


Solution

  • Ok, so the issue was two fold:

    1. I'm aware that github authentication did change in the past few months/years. So, I did change my authentication to username/password.

    I used my github username and a generated token from github as my password (settings -> developer settings -> personal access tokens -> classic -> generate new token)

    1. I didn't have git installed on my amazon linux 2 machine AND the default path to git was for a windows machine. I solved by:
    • ssh-ing to my ec2 instance (hosting Jenkins) and installed git via sudo yum install git
    • Navigating to my jenkins instance and changing the path (path of install can be located w/ command which git (/usr/bin/git). Manage Jenkins -> Tools -> git installations -> (see screenshot below

    enter image description here)

    And now we're good to go!

    enter image description here