Setup SSH between Jenkins and Github

Please visit my website and subscribe to my youtube channel for more articles

https://devops4solutions.com/

In this blog, we will explore how to Setup SSH between Jenkins and Github for achieving the passwordless connection . Using this approach, you do not need to provide your credentials to configure the git repo in your Jenkins job

Agenda:

Prerequisite:

Setup jenkins user on jenkins server

sudo -su jenkinsssh-keygen
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
Image for post
Image for post
Image for post
Image for post

SSH key is generated successfully for the jenkins user

Now copy the .pub file using below command

cat /var/lib/jenkins/.ssh/id_rsa.pub

Github Configuration

Image for post
Image for post

Configure Jenkins Credentials

Add SSH Key inside Jenkins

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

Now you can clone any git repo in this jenkins instance. You do not need to provide the credentials while configuring the job in Jenkins

Configure Jenkins Job

Summary:

Congratulation, we have successfully setup SSH between Jenkins and Github for achieving the password less connection . Using this approach, you do not need to provide your credentials to configure the git repo in your Jenkins job.

Devops Automation Enginneer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store