CSE 373, Winter 2019: SSH Key Guide

What are SSH keys?

SSH keys fill the same role as a username and password, in that they are used to authenticate with servers. The general idea is that you generate a pair of keys using some program, upload one key to servers to associate with your account, then send the other to the server whenever you need to log in instead of using a username and password.

The key meant for sending to servers is called the "public key," and the one for actually authenticating is called the "private key." Make sure you keep your private key to yourself, since anyone can use it to authenticate as you.

You may upload the same public key to many servers if you want to use the same private key for authentication, so feel free to re-use an existing one if you have any already. In this case, you may skip to the second part of this guide: adding the SSH key to GitLab. If you do not have an SSH key yet, you'll need to start with the next section.

Generating an SSH key

We'll refer to the GitLab SSH setup guide for instructions here, but first, some notes:

  • We recommend using the ED25519 algorithm to generate SSH keys, as in the first of the two examples in the guide. You can scroll up to the previous section on that page for some more details.
  • You should leave the key in the default location with the default name so that other applications, such as your IDE, can detect it automatically.

Okay, now that we've gotten that over with, here's the link to the guide.

Assuming that you've generated your keys properly and in the default location, programs such as IntelliJ and the command line version of Git will automatically attempt to use your private key when authenticating with servers.

Need to move your SSH key?

If you already have a key and thus need to save this one somewhere else, you'll need to create a config file at ~/.ssh/config like the following example in order to tell programs where to look for your ssh key:

gitlab.cs.washington.edu
    IdentityFile ~/.ssh/some_key_name

This will tell programs to use the SSH key in "[your home/user directory]/.ssh/config" whenever connecting to the server gitlab.cs.washington.edu (which is the CSE GitLab server).

Adding an SSH key to GitLab

Again, we'll just direct you to GitLab's guide for adding SSH keys.