ASP.Net Web Application Continuous Integration (CI) using Jenkins automation server: Creating & Adding SSH key to Bitbucket

In this blog post, we will see what all steps are involved in creating & adding SSH key to Bitbucket.

Note: You are currently on Part III of this series, do refer below parts for more details.

Part I: Basic Setup, Installation & Configuration

Part II: Starting & setting up Jenkins

Part IV: Creating Jobs In Jenkins: Getting source code from Bitbucket hosted git repository, polling the SCM to check whether changes were made, restore Nuget packages, build project using MSBuild, publish and archive the build

A. Creating SSH key

I. Set up your identity
Open git bash, enter ssh-keygen
$ ssh-keygen
Enter file in which to save the key
Enter and re-enter a passphrase when prompted.

II. Add the key to the ssh-agent
To start the agent, run the following:
$ eval $(ssh-agent)

Enter ssh-add followed by the path to the private key file
I have copied the generated public & private keys to “I:\Jenkins\tools\sshkeys” from “C:\Users\<username>”.
$ ssh-add I:/Jenkins/tools/sshkeys/bitbucketssh

ssh key generation full

B. Adding SSH key to Bitbucket

I. Login to Bitbucket and go to “Bitbucket Settings” page

Bitbucket Settings

II. On “Settings” page, click “SSH keys” under “Security” to go to “SSH keys” page.

SSH Keys

III. On “SSH keys” page, click “Add key”, to open “Add SSH key” dialog.

Add SSH key

On “Add SSH key” dialog, paste the content of public key (bitbucketssh.pub) to the “Key” textbox & click “Add key”.

Add public ssh key to bitbucket1

 

Previous: Starting & setting up Jenkins

Next: Creating Jobs In Jenkins: Getting source code from Bitbucket hosted git repository, polling the SCM to check whether changes were made, restore Nuget packages, build project using MSBuild, publish and archive the build

You may also like...

3 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *