Authenticate Jenkins CI for Github private repository

0 votes
I want Jenkins to automatically fetch data from my private repo hosted on github.

I tried generating the ssh key for Jenkins user and the only thing I can see is “unable to clone the repo”.
Aug 13, 2018 in Jenkins by Hannah
• 18,570 points

1 answer to this question.

0 votes

when you have a server that needs pull access to a single private repo. This key is attached directly to the repository instead of to a personal user account.

If you have a Jenkins user, you can store your deploy key in ~/.ssh/id_rsa. When Jenkins tries to clone the repo via ssh, it will try to use that key.

In some setups you cannot use the default ssh key location. In such cases you create a key in different location(~/.ssh/deploy_key) and configure ssh in ~/.ssh/config.

Host github-deploy-myproject
    User           git
    IdentityFile   ~/.ssh/deploy_key
    IdentitiesOnly yes

we create a host alias github-deploy-myproject because you don’t want to use the above keys to all your github connections. Your clone URL now becomes

git clone github-deploy-myproject:myuser/myproject
answered Aug 13, 2018 by Kalgi
• 52,370 points

Related Questions In Jenkins

0 votes
1 answer

Which is better jenkins of TFS 2015 for CI/CD?

Visual Studio and TFS have been using ...READ MORE

answered Aug 21, 2018 in Jenkins by ajs3033
• 7,280 points
+1 vote
3 answers

How to auto build a job in jenkins if there is any change in code on Github repository?

To automatically run build on code commit, follow ...READ MORE

answered Jul 31, 2019 in Jenkins by Sirajul
• 59,090 points
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer
+1 vote
3 answers
+2 votes
4 answers

Jenkins integration for dotnet test

You can use the following Pipeline code ...READ MORE

answered Aug 8, 2018 in Jenkins by Kalgi
• 52,370 points