Using SSH key with Github


Using SSH key with Github

Beginning August 13, 2021, no longer accepts account passwords when authenticating Git operations.

One of the allowed ways for authenticating Git operations is through using SSH key.

This is a two step process. 1. Generate SSH key 2. Uploading public SSH key to GitHub

1. Generating SSH key

1. Open a terminal (cmd on windows)

2. On your home directory type the following command ssh-keygen -t rsa

3. This will prompt you to enter a filename to store the key. 

  • Just press enter to accept the default filename (/Users/you/.ssh/id_rsa)
  • Then it will ask you to create a passphrase. This is optional, either create a passphrase or press enter for no passphrase
  • When you press enter, two files will be created
    • ~/.ssh/id_rsa
    • ~/.ssh/
  • Your public key is stored in the file ending with .pub, i.e. ~/.ssh/

2. Uploading public SSH key to GitHub

  1. Copy content of your public key file to your clipboard.
  2. Visit
  3. On the left-hand side menu, you will see a link "SSH and GPG keys"
  4. Click on that link which will take you to a page where you can enter your public SSH key that you copied earlier.
  5. Click the button which says ‘New SSH key’
  6. Then enter a title e.g. newMBP
  7. Paste the public SSH key in the key textbox
  8. Click "Add SSH key"

Switching remote URLs from HTTPS to SSH

In case your repository is set to use HTTPS protocol then you will have to switch to SSH to start using SSH key based authentication.

  1. Open Terminal.
  2. Change the current working directory to your local project.
  3. List your existing remotes in order to get the name of the remote you want to change.
    $ git remote -v
    > origin (fetch)
    > origin (push)
  4. Change your remote's URL from HTTPS to SSH with the git remote set-url command.
    $ git remote set-url origin
  5. Verify that the remote URL has changed.
    $ git remote -v
    # Verify new remote URL
    > origin (fetch)
    > origin (push)

With this you should be all set to start using SSH key based github authentication.