GitHub SSH Key Authentication Setup
Setting up secure passwordless SSH keys with GitHub: generating Ed25519 keypairs, ssh-agent configuration, and adding keys to GitHub settings.
GitHub SSH Key Authentication Setup
Using SSH (Secure Shell) keys provides secure, passwordless authentication between your local terminal and GitHub.
1. Generating a Modern Ed25519 SSH Key
The Ed25519 algorithm provides superior cryptographic security and performance compared to legacy RSA keys:
ssh-keygen -t ed25519 -C "your.email@example.com"When prompted:
- Press
Enterto accept the default file location (~/.ssh/id_ed25519). - Enter a secure passphrase (or press
Enterfor no passphrase).
2. Adding Key to SSH Agent
# 1. Start the ssh-agent background process:
eval "$(ssh-agent -s)"
# 2. Add your private key to ssh-agent:
ssh-add ~/.ssh/id_ed25519(On macOS, configure ~/.ssh/config with UseKeychain yes to persist passphrase across reboots).
3. Copying Public Key to GitHub
Copy the contents of your public key (.pub):
# macOS:
pbcopy < ~/.ssh/id_ed25519.pub
# Linux (with xclip):
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
# Or display and copy manually:
cat ~/.ssh/id_ed25519.pub- Go to github.com/settings/keys.
- Click New SSH Key.
- Paste the key into the Key field and give it a descriptive title (e.g. "Work MacBook Pro").
- Click Add SSH Key.
4. Testing Your SSH Connection
ssh -T git@github.comExpected response:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.Related Topics
GitHub Repositories & Collaboration
Understanding GitHub repositories: public vs private repos, README.md, LICENSE, repository settings, and open-source collaboration.
GitHub Personal Access Tokens (PAT)
Understanding Fine-Grained Personal Access Tokens: HTTPS authentication, token scopes, expiration policies, and automated script access.