This guide provides a clear, step-by-step workflow to generate, register, and use SSH keys with GitHub for secure passwordless authentication.
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.
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
Make sure the agent is running:
eval "$(ssh-agent -s)"Add your private key:
ssh-add ~/.ssh/id_ed25519Copy the contents of your public key:
cat ~/.ssh/id_ed25519.pubGo to: GitHub → Settings → SSH and GPG Keys → New SSH Key
Paste the key content.
Test connection:
ssh -T git@github.comSuccess message:
Hi username! You've successfully authenticated...
If your repo is using HTTPS, change it:
git remote set-url origin git@github.com:USERNAME/REPOSITORY.gitCheck result:
git remote -vNow pushing won't require a username or password:
git pushCreate or edit config file:
nano ~/.ssh/configExample setup:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
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.