Setup SSH between Jenkins and Github

3 min readApr 27, 2018

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

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


  1. Setup a user jenkins on your Jenkins server
  2. Generate the SSH keys
  3. Copy the the public key in Github
  4. Configure in Jenkins Credentials
  5. Configure a sample job in Jenkins using SSH connection


  1. Jenkins should be installed
  2. Github account

Setup jenkins user on jenkins server

  • Generate the ssh keys
  • Ensure the ssh-agent is running
sudo -su jenkinsssh-keygen
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

SSH key is generated successfully for the jenkins user

Now copy the .pub file using below command

cat /var/lib/jenkins/.ssh/

Github Configuration

  • Go to Github repository -> Setting ->Deploy Keys

Configure Jenkins Credentials

Add SSH Key inside Jenkins

  • Login to jenkins
  • Navigate to Credentials from left panel in Jenkins console and then click on global or Go to Manage jenkins -> Manage Credentials