Skip to main content

How to create SSH Key for GitHub and Bitbucket


This post demonstrate how to generate SSH private and public key with fundamental steps and assist you to add public key inside your GitHub and Bitbucket account.

But first why we need this SSH public key?

Whether you are working in the team or an individual and you want make any operations on secure GIT repository like clone or push your latest changes then you require to provide your credentials to help GIT to authenticate you and approve those operations.

But when you do so, you are asked to provide your username & passwordeach time on each operation.

It looks simple earlier, but later becomes a headache.

SSH connection helps us to authenticate using public and private keys, that we generate only once, later we don’t need to authenticateSSH will do this behalf of us.

But how does it work?

SSH authenticate you using an identity, your identity and this identity comprise combination of private, public key.

Private Key resides in your local machine and public key inside your GitHub or Bitbucket account.

When you perform any operation on Git repository which requires your identity or authentication, SSH combines these two keys, one from your laptop or PC (private key) and one from GIT repository (public key).

To use SSH, you need to install it first. I assumed that you had already installed it, if not. 
Then please visit and install SSH to your local machine.

Generate private-public keys

Us following steps to generate private and public key, later copy public key and add it in your GitHub and Bitbucket account.

Open terminal and type following command


It will ask location for key files, hit Enter to select default location.

At that time it asked passphrase (password), you can or can't enter your password. It is best to add one.

It will ask re-passhprase

Once done, keys get generated and get saved inside provided location. 
Over here is sample output of ssh-keygen operation.

Next add your key to the ssh-agent.
  ssh-add ~/.ssh/id_rsa    

Later we need to add public key to GitHub and Bitbucket account. To do so, we need get. 
content of public key, this resides inside ~/.ssh path.

  cat ~/.ssh/     

Directly copy this key and visit GitHub or Bitbucket to add it into your account.


Open a browser and log into your GitHub account.
  • Select setting icon from top right corner of menu bar.
  • Then select “SSH keys” from left side panel
  • Now add new public key by selecting “Add SSH key” button. It will open a panel to enter public key.
  • Add label for public key and then add copied public key inside key area.
  • Now finish this process by clicking "Add key" button.

That’s it. You done with GitHub


Open a browser and log into your Bitbucket account.

  • Select Avatar->Manage Account from the application menu.
  • Under Security section Click SSH keys.
  • Then click Add key button. It will prompt a dialog to add public key.
  • Add label for public key and then add copied public key inside key area.
  • Now finish this process by clicking Add key button.

That’s it. You done with Bitbucket.


If you want to make your repository operation smooth then use SSH a convenient and secure tool and follow this guideline.


Post a Comment

Popular posts from this blog

AngularJs Tutorial: Getting Started

This tutorial will help you to create a dynamic web application using power of AngularJs. ·   What is AngularJs AngularJs is javascript MVC framework (maintained by Google) which molds static HTML application to dynamic web application. That was a brief introduction, you can find more information on Wiki and AngularJS Site . AngularJs follows MVC pattern to separate out model from view and manage it by controller. See this image Goal of using AngularJs is to convert static HTML template to dynamic (Angular) template.   ·   How to convert static template to dynamic (Angular) Template Now consider the following static HTML template which contain list of movies title. <html> <head></head> <body>   <h1>Upcoming Movies</h1> <ul>     <li>       <span>Godzilla</span>     </li> <li>       <span>Batman vs Superman</span>     </li> <li>       <span>Sta

AngularJs Tutorials : Bootstrap

Every application starts with bootstrap process which initialize application and wire it other with dependencies and configurations. AngularJs is not different from other application. It also starts application with bootstrap process. Following operation happens inside AngularJs bootstrap process. Load application module. Create dependency injector and load dependencies. Compile HTML and create scope for application. All these steps happens inside angular.js scripting file. therefore we need to include it first. we can include it inside HEAD tag or at end of BODY tag. Note: Adding angular.js file at end of body tag will allow browser to load of HTML elements without any delay and afterwards load angular.js and begin bootstrapping process. You can get angular.js source file from <script src= ”” type= ”text/javascript” > AngularJs bootstrap process happens on docum