# GitHub SSH Setup

One of the most convenient ways to give your computer access to your GitHub account (and with that to your private repositories) is to set up a Secure Shell (SSH) key. The initial process may be a bit intimidating at first, but if you follow all steps exactly as described, you should not run into any issues.

{% hint style="warning" %}
**Note:** For Windows users, it is essential that you **run all given commands from your WSL terminal**. If you are not sure whether you are in your WSL terminal, enter the `uname` command. If you are on WSL, the output should be "Linux", while a Windows terminal will give you an error.
{% endhint %}

***

## Step 1: Generate SSH Keypair

1. Enter `ssh-keygen -t ed25519 -C "<your_email>"`\
   and replace `<your_email>` with the email address used for your GitHub account (but make sure to keep the quotes around the email).
2. When prompted for where to save the key, simply press enter.
3. When prompted for a passphrase either give it a passphrase (but make sure you remember it) or leave it empty and press enter (twice).
4. Enter `eval "$(ssh-agent -s)"`
5. Enter `ssh-add ~/.ssh/id_ed25519`
6. Enter `cat ~/.ssh/id_ed25519.pub` (make sure to include the `.pub` in the filename)\
   The output should look something like: `ssh-ed25519 [...] <your_email>`
7. Copy the output of the previous command (in WSL (Windows) you can copy highlighted text by right-clicking)

***

## Step 2: Add Public Key to GitHub

Now open [GitHub](https://github.com/) in your browser and follow the remaining steps:

1. Click on your user icon and select "Settings".
2. Click on "SSH and GPG Keys" in the sidebar.
3. Click the green "New SSH key" button.
4. Give the key some name (e.g., WSL or MacBook)
5. Paste the output from the `cat` command executed earlier into the "Key" field.
6. Click "Add SSH key"

***

## Step 3: Configure Git

Return to your terminal window and execute the following steps to finish the setup:

* `git config --global user.email "<your_email>"`
* `git config --global user.name "<your name>"`

where you replace `<your_email>` with the email used for your GitHub account (and used during the SSH setup) and `<your name>` with either your GitHub username or your full name depending on your preference.

Done! You should now be ready to go with your Git and GitHub setup.

***

## Step 4: Clone Your Repository

{% hint style="info" %}
**Note:** You should do this step after completing the [GitHub Repository Setup](github-repository-setup).
{% endhint %}

To clone a repository you can simply use the following command:

```bash
git clone git@github.com:<username>/<repo>.git
```

`<username>` is your GitHub username and `<repo>` is the name of your repository. You can also copy this command from the GitHub website of your repository using the green "Code" button and then the "SSH" tab.

The first time you use this command, your terminal will warn you that the authenticity of github.com can't be established. This is because you are using the SSH keypair for the first time. Simply type `yes` and continue.
