Setup SSH between Jenkins and BitBucket

In this story, you will learn how to set up SSH between Jenkins and BitBucket. Using this approach, you do not need to provide your credentials to configure the git repo in your Jenkins job, and you will achieve the password-less connection

Recently other methods have been deprecated for security reasons, and this is the new standard.


  • Generate the SSH keys
  • Copy the public key in Github
  • Configure in Jenkins Credentials
  • Configure a sample job in Jenkins using SSH connection

Configure Jenkins user

Generate the ssh keys and ensure the ssh-agent is running

ssh-keygen sudo eval $(sudo ssh-agent -s) ssh-add ~/.ssh/id_rsa An SSH key is generated successfully and allows you to achieve the password-less connection between Jenkins and BitBucket

Copy the public key using the below command (or where ever your ‘.ssh’ folder is and copy the key)

cat /home/ubuntu/.ssh/

BitBucket Configuration

Go to BitBucket repository -> setting -> SSH keys

              Configure Jenkins Credentials

Now we will configure the private key of the jenkins user in the Jenkins configuration

Add SSH Key inside Jenkins

  • Login to Jenkins
  • Now go to Manage Jenkins from the left panel inside the Jenkins console and then click Manage Credentials:
After this, select ‘Add Credentials’. This will open a new form for us. In the dropdown, select ‘SSH username with private key’ and then give a name for it.

Copy the private key from the Jenkins server.


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

  • Create a freestyle job in Jenkins
  • Configure SSH URL of your git repo

You may also like

August 28, 2023

Critical Thinking in Coding: Your Ladder to Software Mastery?

Is critical thinking a rare talent reserved for a chosen few? Or is it just a myth spread by those hesitant to venture into software development? If you ask us, such a viewpoint weakens the genuine core of critical thinking. Rather than viewing it as an unchangeable quality, consider it an evolving talent that may […]

August 21, 2023

Tech's Cultural Compass: Why Cultural Intelligence Counts

In the busy global IT arena, experts team up worldwide, each with a unique cultural imprint. This international union, however, has its challenges. Cultural differences in conventions and attitudes can sometimes operate as barriers to efficient communication.  Today’s blog post digs into the critical function of cultural intelligence in software development teams, emphasizing its significance […]

September 4, 2023

Why Juniors Should Start in the Office

Remote work sounds like heaven? No doubt! But there’s something special about kicking it off inside an office.  For newcomers to coding, the office atmosphere is like a turbo-charged learning zone – imagine skill-building, tech gossip, and soaking up all those professional vibes.  So, if you’re looking for your first job but shy away from […]