generate ssh keys for git authorization

How to Generate SSH Keys for Git Authorization

Git is a popular distributed version control system. Many git servers authenticate using public SSH keys. If you don’t have a public key, you need to generate one. In such cases, each user needs to provide public SSH key for git authorization. In this article, we will learn how to generate SSH keys for git authorization.


How to Generate SSH Keys for Git Authorization

We will look at how to generate SSH keys for git authorization in Windows, Mac & Linux.


1. Generate SSH Keys in Windows

Here are the steps to generate SSH keys in Windows.

  1. After you have installed git on your Windows system, open git bash by going to Start->All Programs->Git->Git Bash
  2. You will see terminal window. Here type ssh-keygen -t rsa. When prompted, enter password and key name.
  3. Your key file will be located at your_home_directory/.ssh. Open your_home_directory/.ssh/id_rsa.pub in your text editor.
  4. Copy contents to your Git repository’s keys field (obtained from GitHub, Bitbucket, or any other repository provider), under your account. Make sure that you don’t copy whitespace while copying public key’s content.


2. Generate SSH Keys in Mac

Here are the steps to generate SSH keys in Mac.

  1. Open terminal and enter cd ~/
  2. Run the command ssh-keygen -t rsa. When prompted, enter password and key name.
  3. Your key file will be located at ~/.ssh. Open the key file ~/.ssh/id_rsa.pub in text editor.
  4. Copy contents to your Git repository’s keys field (obtained from GitHub, Bitbucket, or any other repository provider), under your account. Make sure that you don’t copy whitespace while copying public key’s content.


3. Generate SSH Keys in Linux

Here are the steps to generate SSH Keys in Linux

  1. Open terminal and enter cd ~/
  2. Run the command ssh-keygen -t rsa. When prompted, enter password and key name.
  3. Your key file will be located at /home/your_username/.ssh. Open the key file /home/your_username/.ssh/id_rsa.pub in text editor.
  4. Copy contents to your Git repository’s keys field (obtained from GitHub, Bitbucket, or any other repository provider), under your account. Make sure that you don’t copy whitespace while copying public key’s content.


4. Submit Public Key

Once you have generated SSH key by any of the above methods, you need to add it to the repository provider like GitHub, BitBucket, etc. Only then the remote server will be paired with your local system. Here is the screen to do so in GitHub.

Once you have submitted your public key, you can start git on your local machine and communicate with remote git server.

In this short article, we have learnt how to generate SSH keys for git authorization in Windows, Linux & Mac.

Also read:

How to Download File in Django
How to Check if File Exists in Python
How to Allow MySQL User from Multiple Hosts
How to Check Python Package Dependencies
How to Check Python Package Path

Leave a Reply

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