Setting Up Your SSH Key

Why Do You Need an SSH Key?

You might be wondering: Why do I even need an SSH Key? Well, an SSH key is like a VIP pass for your computer to access GitHub securely, without needing to type your password every time you use Git. It makes life easier and keeps your account safe.

Here's how it works:

P.S: This means that you'll have to generate an SSH key for every device you plan on using Github with, or at least all the ones where you're going to work with a repo.

How to Generate and Add Your SSH Key

  1. Open your terminal and enter the following command to generate your key pair:
    ssh-keygen -t ed25519 -C "your_email@example.com"

    Replace your_email@example.com with the email you used for GitHub.

  2. When prompted to "Enter a file in which to save the key," press Enter to accept the default file location.
  3. When prompted for a passphrase, either enter one (for extra security) or leave it blank and press Enter.
  4. Now, copy your public key to your clipboard:
    cat ~/.ssh/id_ed25519.pub

    Highlight the output and copy it (you'll need it for the next step).

  5. Go back to GitHub, click on your profile picture in the top-right corner, and navigate to Settings.
  6. Under the "Access" section in the sidebar, select SSH and GPG keys, then click New SSH key.
  7. Paste your public key into the text box, give it a recognizable title (e.g., "My Laptop" or "Macbook Pro [Name]"), and click Add SSH key.
  8. To verify everything's working, go back to your terminal and run:
    ssh -T git@github.com

    If everything's set up correctly, you'll see a message like, "Hi [username]! You've successfully authenticated."