Skip to main content

Add SSH Key to GitHub

This guide walks through adding your SSH public key to GitHub for Git authentication.

Prerequisites

Steps

1. Copy Your Public Key

First, copy your SSH public key to your clipboard.

# Copy to clipboard
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard

# Or display to copy manually
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub

2. Open GitHub SSH Settings

  1. Go to github.com and sign in
  2. Click your profile picture (top right)
  3. Click Settings
  4. In the left sidebar, click SSH and GPG keys

Or go directly to: github.com/settings/keys

3. Add New SSH Key

  1. Click New SSH key
  2. In the Title field, add a descriptive label (e.g., "Work Laptop" or "MacBook Pro 2024")
  3. For Key type, select Authentication Key
  4. In the Key field, paste your public key
  5. Click Add SSH key
  6. If prompted, confirm your GitHub password

4. Verify Connection

Test that your SSH key is working:

ssh -T git@github.com

Expected output:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Troubleshooting

"Permission denied (publickey)"

  1. Verify the key was added: Check github.com/settings/keys
  2. Verify your local key is loaded: ssh-add -l
  3. Try verbose mode to debug: ssh -vT git@github.com

"Key is already in use"

Each SSH key can only be added to one GitHub account. If you need multiple accounts, see SSH Key Setup - Multiple Keys.