How to Add a new SSH Key to GitHub

I am assuming you already have generated your new SSH Key before we learn how to add a new SSH key to GitHub today. You would need the passphrase that you had entered in the above tutorial eventually, so it is better you follow the steps mentioned therein first.

Steps on How to Add a new SSH key to GitHub

Coming from the previous tutorial continue following these steps and you will be able to add a new SSH ket to your Github. Using these steps you would no longer be required to enter your email and password everytime you checkin your code, since your SSH key will store your login credentials now.

Step 1: The first step is to copy the SSH public key to your clipboard.

You can use the clip command for it:

$ clip < ~/.ssh/id_ed25519.pub

NOTE: If you have a different SSH Key name as above, simply replace it with yours.

how to copy key using clip command

Step 2: Now in the browser open your GitHub account and click on the top right side corner of your profile image. Then click on Settings.

settings option in github

Step 3: In the settings page, toward the left sidebar look for the option “SSH and GPG keys“. Click on it.

ssh and gpg keys option in settings

Step 4: When the SSH and GPG keys section opens, look for the button ‘New SSH key’, and click on it.

add new ssh key option

Step 5: Next give a title to your SSH key and paste the SSH key that you had copied to the clipboard in Step 1 in the Key field area.

how to add a new SSH key to Github enter ssh key with title

Step 6: Once you have entered all the details, click on the Green button that says ‘Add SSH key‘.

how to add a new SSH key to Github when ssh key gets added

As you can see the key has been added.

Proceed with the Cloning of Repo Now

Step 7: Now whatever repository you want to clone, just go to that folder, right-click and open the GitBash terminal.

Step 8: Then type the git clone command as we had seen in the cloning a repository tutorial to clone a repository to your local.

add ssh key to github cloning a repo

Step 9: When the cloning starts you might be asked to enter the same passphrase that you had entered while generating your SSH key. Use that and press enter.

You would notice that the cloning will complete and the project would be loaded into your local.

final result

That’s it!

Go on and open the project in your preferred IDE.

If you like this tutorial on how to add a new SSH key to GitHub, please let us know in the comments.

Thank you.

Scottshak

Poet. Author. Blogger. Screenwriter. Director. Editor. Software Engineer. Author of "Songs of a Ruin" and proud owner of four websites and two production houses. Also, one of the geekiest Test Automation Engineers based in Ahmedabad.

You may also like...

1 Response

  1. April 11, 2021

    […] We will talk about how to add a new SSH key to GitHub account in our next tutorial. […]

Leave a Reply