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
-
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.
- After that, start a Terminal. This can be done one of three ways
- On a Mac, start the Terminal program that comes with the system. You can find this application
by hitting the
command-space
combination, then typingTerminal
in the search bar. - On Windows, you can use a command line like Ubuntu or install Git for Windows
- 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:
- On a Mac, start the Terminal program that comes with the system. You can find this application
by hitting the
- 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 (includingclone
,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"
- 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
- Mac:
-
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.
-
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.