Steps
1. Generate an SSH Key
ssh-keygen -t ed25519 -C "your-github-email@example.com"
2. View the Public Key
cat ~/.ssh/id_ed25519.pub
3. Add the Public Key to GitHub
- GitHub → Settings → “SSH and GPG keys”
- “New SSH key” → paste the public key
4. Test the Connection
ssh -T git@github.com
5. Switch Your Remote URL to SSH
git remote set-url origin git@github.com:USERNAME/REPO.git
Common Pitfalls
- Add the public key (
.pub) to GitHub — never share the private key - Existing repositories keep using HTTPS until you update the remote URL
SSH keys work for VPS connections too. You can reuse the same key or manage separate keys per host with How to Use ~/.ssh/config to Simplify SSH Connections.
Related Posts
- How to Push Your First Repository to GitHub
- How to Install Git on Windows and Configure It
- GitHub Actions: Basic Auto-Deploy Setup
- Git Remote Repository Operations
Recommended Services
- Fiverr - Find freelance developers and tech experts