GitHub removed password authentication support from August 13, 2021 instead it recommends to use either OAuth or Personal Access Token. We will see how to connect to GitHub from Jenkins using SSH keys instead of using user name and password.
It is also a good practice to use SSH keys in Jenkins jobs instead of using user name and password.
Watch the steps in YouTube channel:
Pre-requisites:
- Jenkins is up and running
- Credentials plug-in installed in Jenkins
Create SSH keys in your Jenkins EC2 instance
ssh-keygen
enter four times. this will create keys in .ssh folder.
Copy and paste the public key
sudo cat ~/.ssh/id_rsa.pub
Add public Keys into your respective GitHub
Add public keys into your Repository--> settings--> Deploy keys section
Add Private Keys in Jenkins Master
Login Jenkins. Go to Manage Jenkins. click on CredentialsClick on Jenkins
Click on Global Credentials
Choose SSH username with private key
username can be anything
Click on enter directly under private key option and Click Add
Copy and paste private key(not public key) of your from Jenkins instance. command is below:
sudo cat ~/.ssh/id_rsa
copy the content of whole output from above command.
sudo cat ~/.ssh/id_rsa
copy the content of whole output from above command.
Click OK to save.
Now go to any Jenkins Job, you can choose this option for checking out from GitHub. Make sure you enter SSH url not https url.
No comments:
Post a Comment