Appendix

Published

October 24, 2023

Setup GitHub authentication: SSH

  • What is SSH?
    • Secure Shell Protocol
    • Authentication method that uses public and private keys (like a padlock and key)
    • public key goes on GitHub
    • private key stays on your computer

(more detailed instructions available on the Software Carpentry website)

Check for existing keys

  • Enter this in your terminal (it lists files in a folder):
ls -al ~/.ssh
  • If any of these files show up, you already have keys available that you can use to log into GitHub
id_rsa.pub
id_ecdsa.pub
id_ed25519.pub

Create keys

  • If no such keys are already present, we need to create a private/public key pair.

  • Use this command (the -t option specifies which type of algorithm to use and -C attaches a comment to the key):

ssh-keygen -t ed25519 -C "you@youremail.com"

(use your own email address)

  • It will ask where you want you want to save the key. Use the default location.

  • Add a passphrase if you want (more secure, but you will have to enter it frequently).

  • Then, you should see something like this:

Your identification has been saved in /c/Users/Vlad Dracula/.ssh/id_ed25519
Your public key has been saved in /c/Users/Vlad Dracula/.ssh/id_ed25519.pub

This tells you the location of your private and public keys

Copy contents of public key

  • First, get the content of the public key:
cat ~/.ssh/id_ed25519.pub

It should include a long string of letters and numbers.

Copy that exact line with command + c (mac) or control + c (Windows)

Add public key to GitHub

  • Go to https://github.com, click on your profile icon in the top right corner to see the drop-down menu
  • Click “Settings,” then “SSH and GPG keys”
  • Click the “New SSH key” button on the right side
  • Enter a name that you will remember (for example, “Joel’s Laptop”), paste your SSH key into the field, and click “Add SSH key”

Check that it worked

  • Run this command to check that it worked
ssh -T git@github.com

Now, you can use git commands without providing a password every time