Jenkins Generate Ssh Key For Bitbucket

Feb 12, 2018 A private key(idrsa) saved to your Jenkins and a public key uploaded to Bitbucket. Bitbucket uses the key pair to authenticate anything the associated account can access. This two-way mechanism prevents man-in-the-middle attacks. Just ignore the username; add your access key as an SSH key credential in Jenkins and put whatever you want in the username field. When you clone a Bitbucket repository using SSH keys you almost always use git as the username anyway. I generated the SSH keys on my local pc (where the Jenkins is installed) cmd prompt and configured the SSH keys (private in Jenkins) and public in my bitbucket repos. Also I installed bitbucket plugin and webhook on Jenkins. When I tried to create a new Item (proj) on Jenkins and entered the URL of my bitbucket repos (SSH URL.

What does SSH Keys do in Github / Bitbucket?

Set up SSH to reduce the risk of exposing your username and password.Some reasons you might want to use SSH key base authentication:

  • Is more effective if you push and pull from Bitbucket many times a day.
  • Removes the need to enter a password each time you connect.

Url formats of the repository differs from HTTPS to SSH:

Environment

  • Operating System : Ubuntu 16.04 LTS (64-bit)

Add SSH Keys in Ubuntu 16.04

The following steps showed the step by step installation guideline.

Set up your default identity

Jenkins Generate Ssh Key For Bitbucket

Generate Ssh Key Bitbucket Windows

From the terminal, enter ssh-keygen at the command line.The command prompts you for a file to save the key in:

It will create two files; one public key file and one private key file.Both file will have your given name.

Add Key files in local machine

Bitbucket Ssh Key Windows

Keep both of the files in ~/.ssh location. Activation key generator for windows 8.1.

Add the public key to your bitbucket settings

  1. In Bitbucket go to Bitbucket settings>Account settings>SSH keys>Add key
  2. Copy the contents of your public key file using the following command:

N.B.: id_rsa is the name I have given when generating the key files. It might be something else for your case.3. /sims-3-ambitions-cd-key-generator.html. Copy and paste the public key in the key field in Bitbucket and include proper label. Click Save.

Ensure Bitbucket SSH connects successfully

Return to the terminal window and write:

For github

Bitbucket

Give your passphrase which you have given when generating the key files.If your connection is successful then you will get output like following:

For Github:

References

  • Set up an SSH key: Bitbucket documentation
  • Change existing folder remote url: Github documentation