Setting Up SSH Through Github

In order to authenticate in Github, we must first setup a SSH key. If you're curious about SSH, you can read about it here. The steps we'll be following are simple: generate a SSH key locally, copy the public key to your Github account and then we'll clone a repo to ensure it's working correctly.

Generate a SSH Key

First, we'll generate the SSH key. Run the following in your shell with your email replaced:

ssh-keygen -t ed25519 -C "your_email@example.com"

It will then prompt you for the location you want to store your SSH keys. Just hit enter, as the default location of ~/.ssh if fine.

Next, it will prompt you for a passphrase. You can just hit enter if you would like. Passphrases are not required, but they are an extra layer of security.

Add Public Key to Github

Now that you have your SSH key generated, we have to enter the public key into Github. You can do this by logging into Github and going to settings.

Then navigate to the SSH and GPG keys section and click on the New SSH Key button.

At this point, you can enter a title such as Macbook Air or whatever you would like as an identifier. Then copy your public SSH key into the Key field. You can get this by running the following command in your shell. It will copy your public key onto your clipboard so you can paste it:

pbcopy < ~/.ssh/id_ed25519.pub

Note that your ssh public file will likely be named different. So you can ls in your .ssh directory to see the name so you can copy the file contents.

At this point, the above form should be filled out. Press the Add SSH Key button and then you you're ready to go! Now you can test that your SSH is working by cloning and pushing to a repo.

Reference

If you had trouble with any of these steps, documentation on this process can be found in the following links. First go through the section Generating a new SSH key and then Adding a new SSH key to your account.