GitHub SSH Key Setup Guide
This guide provides a clear, step-by-step workflow to generate, register, and use SSH keys with GitHub for secure passwordless authentication.
๐ 1. Check Existing SSH Keys
Before creating a new key, check whether your system already has one:
ls ~/.sshIf you see files like:
id_rsa/id_rsa.pubid_ed25519/id_ed25519.pub
You already have SSH keys.
๐ 2. Generate a New SSH Key
GitHub recommends the modern ed25519 algorithm:
ssh-keygen -t ed25519 -C "your_email@example.com"Press Enter to accept defaults.
Your keys will be saved to:
~/.ssh/id_ed25519~/.ssh/id_ed25519.pub
๐ง 3. Start the SSH Agent
Make sure the agent is running:
Add your private key:
๐ 4. Add Public Key to GitHub
Copy the contents of your public key:
Go to: GitHub โ Settings โ SSH and GPG Keys โ New SSH Key
Paste the key content.
๐ฐ 5. Verify SSH Authentication
Test connection:
Success message:
๐ 6. Convert Repository Remote URL to SSH
If your repo is using HTTPS, change it:
Check result:
๐ 7. Push Using SSH
Now pushing won't require a username or password:
๐งฐ Optional: SSH Config for Multiple Keys
Create or edit config file:
Example setup:
โ
Summary
With SSH keys set up, you can:
Push & pull without typing username/password
Securely authenticate to GitHub
Use multiple repos and accounts smoothly
Your Git workflow becomes faster and more secure.
If you'd like, I can also add:
Windows + WSL2 SSH setup
Multi-account GitHub SSH setup
Auto script to convert all local repos to SSH URLs.
Last updated