EDDYMENS

Eddymens (List page)

Last updated 2023-07-23 17:18:23

SSH Setup For Cloning GitHub Repositories

Table of contents

Introduction

GitHub SSH Cloning option [→]

If you ever try cloning a repository using the SSH option you might end up with an error along the lines of The authenticity of the host 'github.com **** can't be established'.

This error may show up for many different reasons. One of the commonest reasons is that you are yet to set up GitHub authentication using SSH. In this tutorial, we will look at the steps to get that done.

Note: Everything in this tutorial was done on macOS.

Generating your public key

To authenticate using SSH we will need to generate a public SSH key and then add this on GitHub so it can automatically authenticate us whenever we try to connect.

Use the command below to generate a public key using your terminal.

$ ssh-keygen -o -t rsa

You should get a couple of prompts when you run the above command. You can roll with the defaults or change them if you are comfortable doing so.

Once the prompts are done your public key should be created and somewhere within the flood of output from the terminal you will find a line similar to what is shown below

01: Your identification has been saved in /User/yourUsername/.ssh/id_rsa.pub

We are interested in the path shown at the end, thus /User/yourUsername/.ssh/id_rsa.pub. This is where the public key is stored.

Note: The path will be slightly or greatly different from the one shown above.

You can now run the command below to display your public key.

$ cat /User/yourUsername/.ssh/id_rsa.pub

Adding your public key to GitHub

Accessing the Settings Page on GitHub [→]

First click on your profile image to the far right and click on settings.

Accessing the SSH Page on GitHub [→] Next, select the "SSH & GPG Keys" option from the left-hand menu.

Accessing the SSH New Page on GitHub [→] From here click on the New SSH Key button to add your SSH key.

Try cloning now

You can now go ahead and try cloning the repository. You might receive a prompt with the following Are you sure you want to continue connecting (yes/no/[fingerprint]) Type in yes to continue.

Here is another article you might like 😊 "Using Surreal DB with Laravel|PHP"