Beginner's Guide: How to Authenticate Your Mac to GitHub

Tutorials
Beginner's Guide: How to Authenticate Your Mac to GitHub

October 9, 2024

Beginner's Guide: How to Authenticate Your Mac to GitHub

Step 1: Create a GitHub Account

  1. Go to github.com
  2. Click "Sign up"
  3. Follow the instructions to create your account

Step 2: Install Git on Your Mac

  1. Open Terminal (find it in Applications > Utilities)
  2. Type this command and press Enter:
    git --version
    
  3. If Git is not installed, you'll be prompted to install it

Step 3: Set Up Git

In Terminal, set your name and email:

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"

Step 4: Check for Existing SSH Keys

  1. In Terminal, type:
    ls -al ~/.ssh
    
  2. Look for files named id_rsa.pub, id_ecdsa.pub, or id_ed25519.pub
  3. If you see any of these, you already have SSH keys

Step 5: Generate an SSH Key (if needed)

If you don't have existing keys or want to create new ones:

  1. In Terminal, type:
    ssh-keygen -t ed25519 -C "your_email@example.com"
    
  2. Press Enter to accept the default file location
  3. You can set a passphrase for extra security or press Enter twice for no passphrase

Step 6: Add SSH Key to GitHub

  1. Copy your SSH key to clipboard:
    • For new keys: pbcopy < ~/.ssh/id_ed25519.pub
    • For existing keys: pbcopy < ~/.ssh/id_rsa.pub (or the name of your existing public key)
  2. Go to GitHub.com and log in
  3. Click your profile photo > Settings
  4. Click "SSH and GPG keys" in the sidebar
  5. Click "New SSH key"
  6. Give your key a title (e.g., "My Mac")
  7. Paste your key into the "Key" field
  8. Click "Add SSH key"

Step 7: Test Your Connection

In Terminal, type:

ssh -T git@github.com

If successful, you'll see a message like "Hi username! You've successfully authenticated..."

Congratulations! You're now authenticated to use GitHub from your Mac, either with your new or existing SSH keys.