Note
It is no longer necessary to configure SSH or create a personal access token when using Visual Studio Code for CS50 at cs50.dev. Both check50
and submit50
should "just work," so long as you have logged into submit.cs50.io at least once.
Tools like check50 and submit50 rely on git
, a popular tool for saving different versions of code, and GitHub, a popular website for saving those versions in the cloud. To push (i.e., save) your code to GitHub using git
, it used to be possible to log into GitHub via a command line (as in a terminal window) using a GitHub username and password. As of August 13, 2021, that's no longer possible, which means you can no longer use check50
or submit50
using your GitHub username and password either.
But you can still use check50
and submit50
! You just need to log in a bit differently, either using SSH or a personal access token. Odds are you'll find SSH more convenient for Visual Studio Code and CS50 IDE, and personal access tokens more convenient for CS50 Sandbox and CS50 Lab.
- Open a terminal window, if not open already, within Visual Studio Code, CS50 IDE, CS50 Sandbox, or CS50 Lab.
- Execute
ssh-keygen
. When prompted to "save the key," just hit Enter, without typing anything. - You'll then be prompted for a "passphrase" (i.e., password). If you only use your GitHub account for CS50, no need to input a passphrase; just hit Enter. Otherwise, input a passphrase (that you won't forget!), then hit Enter, then input it again, then hit Enter again. For security's sake, you won't see what you type. You'll then see a "randomart image" that you can ignore.
- Execute
cat ~/.ssh/id_rsa.pub
. You'll then see your "public key," multiple lines of seemingly random text. Highlight and copy all of those lines, starting withssh-rsa
to the end. But don't highlight your terminal window's prompts (which contain$
) before or after those lines. - Visit https://github.com/settings/keys, logging in with your GitHub username and password as usual. Don't use the passphrase you just created, if any.
- Click New SSH Key.
- Paste your public key into the text box under Key. Optionally input a title under Title (e.g.,
CS50
). - Click Add SSH Key.
- Execute
ssh -T [email protected] -p 443
. - Enter "yes" and press enter if you see the following prompt (the IP address might be different):
The authenticity of host '[ssh.github.com]:443 ([140.82.113.35]:443)' can't be established. ED25519 key fingerprint is SHA256:7KMZvJiITZ+HbOyqjKJV2AeC5As3GSZES5abcd1NIe4. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])?
- If you input a "passphrase" (i.e., password) earlier, enter the passphrase and press Enter when you see the following prompt
"Enter passphrase for key 'home/ubuntu/.ssh/id_rsa':"
- You should be greeted with
"Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access."
If you don't see that, review the above steps to verify you didn't skip something.
You should now be able to use check50
and submit50
(and git
) without GitHub username and password. But if you created a passphrase, you might still be prompted for that.
- Visit https://github.com/settings/keys, click Delete next to your old SSH key, then click I understand, please delete this SSH key.
- Follow all of the same SSH steps, above, again. When prompted to "overwrite" (your old key), input
y
, then hit Enter.
- Visit https://github.com/settings/security, logging in with your GitHub username and password as usual, and configure two-factor authentication.
- Visit https://github.com/settings/tokens.
- Click Generate new token.
- Input a note under Note (e.g.,
CS50 IDE
if using CS50 IDE). - Select No expiration (or something shorter) via the drop-down menu under Note.
- Check repo under Select scopes.
- Click Generate token.
- Highlight and copy the "personal access token" that appears. Odds are it will start with
ghp_
. - Paste that personal access token somewhere safe (e.g., in a password manager).
You should now be able to use check50
and submit50
(and git
) without GitHub username and password. When prompted to log in, use your GitHub username and that personal access token instead of your password.
- Visit https://github.com/settings/tokens, click Delete next to your old personal access token, then click I understand, delete this token.
- Follow all of the same Personal Access Token steps, above, again.