Cloning a repository from GitHub by using SSH key

Dulya Kemali Perera
2 min readNov 19, 2019

--

This article hopes to help people to understand, how to clone a repository from GitHub. Someone get confused when cloning a repository from GitHub.

Before you clone a repository better to have an SSH (Secure Shell) key. That SSH uses to authenticate the remote computer and allow it to authenticate the user, if necessary. So if you want to generate the SSH key using below steps.

Generate SSH key

1. Open a command window.

2. Type ssh-keygen.

3. The process of key generation will start. It asks for the file in which to save the key with other related information. (However, you can leave it empty, and it’ll generate your first key with the default name as id_rsa.pub)

4. Now copy the contents of the SSH key and add to the GitHub account. For that type the following:

cat ~/.ssh/id_rsa.pub

Clone a Repository

  1. On GitHub, navigate to the main page of the repository.
  2. Under the repository name, click Clone or download.
Step 2

3. To clone the repository using HTTPS, under “Clone with HTTPS”, copy the URL. To clone the repository using an SSH key, including a certificate issued by your organization’s SSH certificate authority, click Use SSH, then copy the URL.

Step 3

4. Open Git Bash.

5. Change the current working directory to the location where you want the cloned directory to be made.

6. Type git clone, and then paste the URL you copied in Step 3.

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY

7. Press Enter. Your clone will be created.

--

--