Skip to main content

How to create an SSH key for GitHub and Bitbucket

SSH Key



This post will show you how to generate SSH private and public keys step by step, as well as how to add public keys to your GitHub and Bitbucket accounts.

But first, why do we require this SSH public key?

If you want to do any work on a secure GIT repository, such as cloning or pushing your latest changes, you will need to provide your credentials to help GIT authenticate you and approve those operations, whether you are working in a team or as an individual.

However, each time you operate, you are prompted to enter your username and password.

It appears simple at first, but it quickly becomes a source of frustration.

To overcome the above problem, we can use the SSH protocol. SSH connections allow us to authenticate using public and private keys that we generate only once. after that, we don't need to authenticate because SSH will do so on our behalf.


But how does it work?

SSH authenticates you using an identity, and this identity is made up of a combination of private and public keys.

A private key is stored on your local machine, while a public key is stored on your GitHub or Bitbucket account.
When you perform any operation on a Git repository that requires your authentication, SSH combines these two keys.


To use SSH, you must first install it. Please follow the steps given in the following link.
http://www.openssh.com


Generate private-public keys

Follow the steps below to generate a private and public key.
Open a terminal and enter the following command.


  ssh-keygen            

It will request the location of key files. To select the default location, press Enter.

It will then request a passphrase (password). You can omit it, but it is preferable to include one.

After that, it will prompt you to reenter your password for confirmation.

After that, keys will be generated and saved in the specified location.

Here's an example of the ssh-keygen operation's output.





Next, add your key to the ssh-agent.

  ssh-add ~/.ssh/id_rsa    

Later, you need to add the public key to your GitHub and Bitbucket accounts. To do so, we need to get content of the public key. This resides inside ~/.ssh path.


  cat ~/.ssh/id_rsa.pub     

Copy this key and go to GitHub or Bitbucket to add it to your account.

GitHub

Log in to your GitHub account in a browser.

  • Select the setting icon from the menu bar's top right corner.
  • Then select "SSH keys" from the left side panel.
  • Now add the new public key by selecting the "Add SSH key" button. It will open a panel to enter a public key.
  • Add a label for the public key and then add the copied public key inside the key area.
  • Now finish this process by clicking the "Add key" button.
That’s it. The configuration for GitHub is done.

Bitbucket

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.

This will complete the configuration for Bitbucket.

Conclusion

If you want your repository to run smoothly, use SSH with public and private key configuration.

Comments

Post a Comment

Subscribe for latest tutorial updates

* indicates required

Popular posts from this blog

Preload Images Using Javascript

Preload Image is technique which helps browser to render images with minimum delay. Today we will see example of image gallery. Gallery contain 5 images which load images one after another whenever user clicks next and back button. This is a basic image gallery scenario which is used in all possible website, then why we need preloaded images for this gallery? Now a day’s most of website becoming faster and user expectation is increasing. Suppose your website doesn’t use preload image technique for gallery and a user visits any image gallery from Google Plus or Facebook and visits your website gallery. Then that user always prefer those websites rather than yours. Why? Because your website load one image at a time. When user click on next button, then only gallery load image and user has wait till it get loaded. To avoid this situation gallery needs to download all images

CSS: How To Create Custom Scrollbar For Webkit Supported Browsers

In this tutorial, we will learn how to create a custom scroll bar using custom CSS styles. Custom scrollbars are becoming increasingly popular, and I'm excited to learn more about them. A scrollbar can be customised for a variety of reasons. The default scrollbar, for example, can make an app's UI look inconsistent across various versions of windows, thus we can benefit from having a single style here. This tutorial will help to create a custom scrollbar. Let's see how One of the most interesting aspects of these scrollbars is that they may be rendered in a variety of styles for different HTML elements on the same webpage. We will see the implementation of such a scrollbar for Webkit-supported browsers. First we will look at the basic CSS properties of the scrollbar. ::-webkit-scrollbar              ::-webkit-scrollbar-thumb        ::-webkit-scrollbar-track        ::-webkit-scrollbar-button       ::-webkit-scrollbar-track-piece  ::-webkit-scrollbar-cor

AJAX - How To Retrieve JSON Response from PHP script

Hello Friends, This is my first tutorial post. Today I'll explain you how to retrieve JSON response via Ajax call. First we build a PHP script to send response in JSON format, then we will gather this response from an Ajax call through jQuery script. Let’s first create a PHP script  Create a PHP script, I’ll name it as “json_response.php” And add following code in it json_response.php <?php //set header for JSON response header("Content-Type: application/json"); //render array in JSON format echo json_encode(array('status' => 200, 'message' => 'Response from PHP script in JSON format.')); This is a basic example to send JSON response. PHP script will send response with status code and message. Now create a HTML file to fetch JSON response and add it in header tag. Create a HTML file, I’ll name it as “json_response.html” And add following code. json_response.html <html>