We are going to use GitHub for the part of the hands-on where you will be working together in groups, as well as part of the "Working with remotes" section.
and sign up for an account if you do not already have one.
You will need to setup 2FA also.
Create a new SSH key for GitHub - Linux and macOS
This part will be repeated tomorrow before the section "Teamwork", but you should create and add your SSH key to GitHub now if you are doing the hands-ons for the "Working with remotes" section.
Open a terminal. In the command below, "GitHub" is a label added to the key for clarity. You can add any text you want: a. Do this
$ ssh-keygen -t ed25519 -C "GitHub"
b. If you have an older system, this may work better
$ ssh-keygen -t rsa -b 4096-C "GitHub"
You will be asked for a file to save the key. Unless you have an existing SSH key, accept the default.
Enter a passphrase and repeat it.
Create a new SSH key for GitHub - Linux and macOS, continued
Add the key to the ssh-agent. Here we assume the default name for the newer systems - change to what your key was called (if you used the option for legacy systems, it would as default be called id_rsa):
Switch to the .ssh folder, open the file id_ed25519.pub (id_rsa.pub for legacy systems) and copy the entire contents. Do NOT add any newlines or whitespace!
Create a new SSH key for GitHub - Windows
This part will be quickly repeated tomorrow before the section "Teamwork", but you should create and add your SSH key to GitHub now if you are doing any of the hands-ons for the "Working with remotes" section.
Open Git Bash. In the command below, "GitHub" is a label added to the key for clarity. You can add any you want: a. Do this
$ ssh-keygen -t ed25519 -C "GitHub"
b. If you have an older system, this may work better
$ ssh-keygen -t rsa -b 4096-C "GitHub"
You will be asked for a file to save the key. Unless you have an existing SSH key, accept the default.
Enter a passphrase and repeat it.
Create a new SSH key for GitHub - Windows, continued
Add the key to the ssh-agent. Here we assume the default name for the newer systems (on the legacy systems it would be id_rsa instead) - change to what your key was called:
Switch to the .ssh folder, open the file id_ed25519.pub (id_rsa.pub on legacy systems) and copy it. Do NOT add any newlines or whitespace!
Adding the SSH key to GitHub
On GitHub, click your avatar in the top right corner and pick "Settings".
Choose "SSH and GPG keys"
Click "Add new SSH key"
Add a descriptive label for the key in the "Title" field. In the key field you paste the content of the key (~/.ssh/id_rsa.ed25519.pub or ~/.ssh/id_rsa.pub)
Click "Add SSH key"
Confirm your GitHub password if you are prompted for it.
Testing the SSH keys
Open a terminal / the Git bash
$ ssh -T git@github.com
It will look similar to this:
$ ssh -T git@github.com
The authenticity of host 'github.com (140.82.121.3)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
ECDSA key fingerprint is MD5:7b:99:81:1e:4c:91:a5:0d:5a:2e:2e:80:13:3f:24:ca.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,140.82.121.3' (ECDSA) to the list of known hosts.
Hi bbrydsoe! You've successfully authenticated, but GitHub does not provide shell access.
Verify that the resulting message contains your username.
Introduction to Git – - Fall 2023 Lecture C: Brief intro to SSH-keys and using GitHub Slides: https://hackmd.io/@git-fall-2023/LC-github#/
{"title":"Lecture C: Brief intro to SSH-keys and GitHub","description":"Git installation etc","contributors":"[{\"id\":\"70f80b64-a87f-47db-ba95-b3b587a1530d\",\"add\":6257,\"del\":691}]"}