Skip to content

Git key setup

Christopher Strøm edited this page Jan 24, 2022 · 7 revisions

Since the fall of 2021, authenticating with GitHub through username/password in the terminal has been deprecated, and so to fully utilize our GitHub page, you will need to set up your SSH keys and PAT (Personal Access Token)

Firstly, if you have not set up git already, configure your name and email by

git config --global user.name "FIRST_NAME LAST_NAME"

and

git config --global user.email "[email protected]"

SSH keys

Open a terminal window

Run the following command, substituting in your GitHub email address.

ssh-keygen -t ed25519 -C "[email protected]"

When prompted, just press enter until you are done. You now have an ssh key on your local computer. You will now need to add this to your GitHub account:

  1. Run the following commands to get the key you just generated copied to your clipboard:
sudo apt update
sudo apt install xclip
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
  1. In the upper-right corner of any page (on GitHub), click your profile photo, then click Settings.
  2. In the user settings sidebar, click SSH and GPG keys.
  3. Click New SSH key or Add SSH key.
  4. In the "Title" field, add a descriptive label for the new key.
  5. Paste (CTRL-V) your key into the "Key" field. IF you did step 1 correctly, it will already be in your clipboard
  6. Click Add SSH key.

PAT

A Personal Access Token is a way to authenticate yourself without the use of a username/password combination. We reccomend using libsecret to do this:

  1. Run the following commands to setup git with libsecret:
sudo apt-get install libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
  1. The next time you are promted to authenticate with username/password through git, you will need to paste in a PAT for both - so you will need a PAT in the first place:
  2. In the upper-right corner of any page, click your profile photo, then click Settings.
  3. In the user settings sidebar, click Developer settings, then Personal access tokens
  4. Click "Generate new token" to set up a new PAT
  5. Give your PAT a descriptive name.
  6. Set the expiration date to whatever you like, but note that once the key expires, you will need to go through this process again.
  7. Select whatever scope you wish the PAT to have -> Full access (checking every box) is fine for this purpose, but do as you please.
  8. Click "Generate token" and COPY the token - you will only get this one chance to see it!
  9. Next time you are prompted for your username and password in the git terminal, paste this token in for both your username and password
  10. You will now never have to worry about authentication again, until the token expires!