Skip to the content.
This is the Spring 23 final website.

Setting up GitLab Key

Preface/Explanation

We use git to distribute our starter code (from GitLab) and as a way for you to securely back up your assignments as well as turn them into Gradescope.

In order to use git we need some way for our computer to tell GitLab we are who we say we are. To do this, we will use a “key” which is a random string of character that only our computer and GitLab know. These characters are used whenever we use git.

Background

This information can be found in Gitlab’s help on using SSH keys, however, we thought it might be easier to see a distilled down version with images along with the steps.

Steps

  1. Navigate to https://gitlab.cs.washington.edu/users/sign_in where you will sign in to GitLab for the first time. Use your CSE ID if you are in the CSE major. Otherwise, use your UW NetID.

    :img Gitlab sign in screen with a choice of UW or CSE net id log in, 80%, width

  2. After that, start a Terminal. This can be done one of three ways
    1. On a Mac, start the Terminal program that comes with the system. You can find this application by hitting the command-space combination, then typing Terminal in the search bar.
    2. On Windows, you can use a command line like Ubuntu or install Git for Windows
    3. You can start Android Studio and create a new application (doesn’t matter what type of activity you pick). At the bottom of the window you’ll see a strip of subwindows you can expand, including the terminal:

    :img Opening up Android Studio Terminal, 80%, width

  3. Once you start a terminal window, you need to run the following command to generate a unique key to identify your computer with your email address substituted in.
    • LEAVE THE FILE BLANK! (It will break things if you don’t) Just hit enter to keep the default. If it prompts you to overwrite the file, type y then hit enter.
    • You may also want to leave the passphrase blank - while it is more secure to have a passphrase, you will be prompted for it any time you do a git command (including clone, add, commit, push) and you may have to re-enter the passphrase. There is no way to retrieve the passphrase if you forget it.
    • The GitLab documentation cites another source that suggests ED25519 keys might be more secure at this point than RSA keys. It is up to you whether you explore this option, however, the command below would need to change accordingly.
     ssh-keygen -o -t rsa -b 4096 -C "YOUR_EMAIL_ADDRESS@EXAMPLE.COM"
    

    :img Gitlab key generation in Mac Terminal, 80%, width

  4. Then, copy this unique key to our computer’s clipboard by running the following command:
    • Mac: pbcopy < ~/.ssh/id_rsa.pub
    • Windows: cat ~/.ssh/id_rsa.pub | clip

    :img Using pbcopy in Mac Terminal, 80%, width

  5. With the key copied, navigate to https://gitlab.cs.washington.edu/-/profile/keys. There you will paste your copied key into the text-box and press the Add key button.

    :img Pasting the key into the gitlab profile key, 80%, width

  6. Confirm that you set the key up correctly by navigating to the Terminal window again and running: ssh -T git@gitlab.cs.washington.edu. If the prompt asks “Are you sure you want to continue connecting? “ say yes. Ultimately you should see Welcome to GitLab as a response.

    :img Checking the key worked, 80%, width