Add SSH Key to GitHub
This guide walks through adding your SSH public key to GitHub for Git authentication.
Prerequisites
- A GitHub account
- An SSH key pair (see SSH Key Setup)
Steps
1. Copy Your Public Key
First, copy your SSH public key to your clipboard.
- Windows
- macOS
- Linux
# 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
# Copy to clipboard
pbcopy < ~/.ssh/id_ed25519.pub
# Or display to copy manually
cat ~/.ssh/id_ed25519.pub
# Copy to clipboard (requires xclip)
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
# Or display to copy manually
cat ~/.ssh/id_ed25519.pub
2. Open GitHub SSH Settings
- Go to github.com and sign in
- Click your profile picture (top right)
- Click Settings
- In the left sidebar, click SSH and GPG keys
Or go directly to: github.com/settings/keys
3. Add New SSH Key
- Click New SSH key
- In the Title field, add a descriptive label (e.g., "Work Laptop" or "MacBook Pro 2024")
- For Key type, select Authentication Key
- In the Key field, paste your public key
- Click Add SSH key
- 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)"
- Verify the key was added: Check github.com/settings/keys
- Verify your local key is loaded:
ssh-add -l - 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.
Related
- SSH Key Setup - Generate SSH keys
- Add Signing Key to GitHub - For commit signing
- GitHub SSH Documentation