title |
---|
Setup |
There are no files required for this lesson. You will create all the files needed.
You will need a GitHub account to follow this course. Sign up if you don't already have an account.
Git is free and open-source software, available for all operating systems.
Git for Windows is available for self-installation from the Software Centre (search for 'git').
See here for installation instructions for the major operating systems.
Please set up SSH keys for authentication with GitHub. This is a two step process:
SSH is an encrypted network protocol which we will use to securely access our remote repository. In order to use it, we need to set up a pair of SSH keys, which are used together to validate access. There's a private key, and a public key - GitHub needs to know the public key, but the private key stays only on your computer. A useful analogy is to think of the public key as a padlock, and the private key as the only key to the padlock.
Let's first check whether we already have ssh keys set up:
$ ls ~/.ssh
{: .language-bash}
If you already have ssh keys set up, your output will look something like this:
id_ed25519 id_ed25519.pub
{: .output}
and you can skip to the next section (Add public ssh key to GitHub).
If you still need to set up ssh keys, you'll get a message like this:
ls: cannot access '/home/yourusername/.ssh': No such file or directory
{: .output}
To set up the key pair, we use the following command
$ ssh-keygen -t ed25519 -C "[email protected]"
{: .language-bash}
You might get an error from this if your system doesn't support
the ed25519 algorithm, in which case you can try
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/you/.ssh/id_ed25519):
{: .output}
Accept the default option using Enter.
Created directory '/home/you/.ssh'.
Enter passphrase (empty for no passphrase):
{: .output}
Enter a password (you'll be prompted to enter it twice)
Your identification has been saved in /home/you/.ssh/id_ed25519
Your public key has been saved in /home/you/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:SMSPIStNyA00KPxuYu94KpZgRAYjgt9g4BA4kFy3g1o [email protected]
The key's randomart image is:
+--[ED25519 256]--+
|^B== o. |
|%*=.*.+ |
|+=.E =.+ |
| .=.+.o.. |
|.... . S |
|.+ o |
|+ = |
|.o.o |
|oo+. |
+----[SHA256]-----+
{: .output}
Now that we have generated the SSH keys, we will find the SSH files when we check.
$ ls ~/.ssh
{: .language-bash}
id_ed25519 id_ed25519.pub
{: .output}
We can view the public key using
$ cat ~/.ssh/id_ed25519.pub
{: .language-bash}
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDmRA3d51X0uu9wXek559gfn6UFNF69yZjChyBIU2qKI [email protected]
{: .output}
Now you should copy the output from this command ready for the final step.
The final step is to add the public key to our GitHub accounts.
- On GitHub, click on your profile icon in the top right corner
- Click “Settings,” then on the settings page
- Click “SSH and GPG keys”
- Click the “New SSH key” button on the right side.
- Add a title e.g. "my_work_laptop" and paste your SSH key into the field, and click on “Add SSH key” to complete the setup.
You can verify your SSH set up was successful like this:
$ ssh -T [email protected]
{: .language-bash}
Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.
{: .output}
As we will see in [episode 2], the default branch name in a git repo is master.
In 2021 GitHub and many other remote repo providers changed their settings so that new repositories will use main instead of master. As ever there are arguments for and against this change. We can however choose the default branch name in our GitHub settings, so let's set it to master to be consistent with the git software itself.
On GitHub, click on your profile photo at the top right of the page. Then go to Settings -> Repositories -> Repository default branch.
Change 'main' to 'master' and click 'update'.
Please get in touch before the course starts if you run into any problems with set up!
[episode 2]: {{ page.root }}{% link _episodes/02-local.md %}