Setup SSH between Jenkins and BitBucket
November 1, 2022
November 1, 2022
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.
Steps
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_rsaCopy the public key using the below command (or where ever your ‘.ssh’ folder is and copy the key)
cat /home/ubuntu/.ssh/id_rsa.pub
BitBucket Configuration
Go to BitBucket repository -> setting -> SSH keys
Now we will configure the private key of the jenkins user in the Jenkins configuration
Add SSH Key inside Jenkins
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