This guide explains how to generate and add SSH keys for GitHub authentication.
Run:
ls -l ~/.ssh/id_ed25519.pub- If the file exists, skip to Step 3.
 - If not found, move to Step 2.
 
Run:
ssh-keygen -t ed25519 -C "[email protected]"- When prompted for a location, press ENTER to accept the default.
 - When asked for a passphrase, press ENTER (or set a passphrase for security).
 
Start the SSH agent:
eval "$(ssh-agent -s)"Add your key:
ssh-add ~/.ssh/id_ed25519Verify the key is added:
ssh-add -lShow the key:
cat ~/.ssh/id_ed25519.pubCopy the output (starting with ssh-ed25519).
- Go to GitHub → Settings → SSH and GPG Keys:
https://github.com/settings/keys - Click "New SSH Key".
 - Set a Title (e.g., "My Linux Machine").
 - Paste the copied SSH key.
 - Click "Add SSH Key".
 
Run:
ssh -T [email protected]If successful, you should see:
Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.
Check your GitHub remote URL:
git remote -vIf it uses HTTPS (https://github.com/...), change it to SSH:
git remote set-url origin [email protected]:yourusername/repository.gitNow, you can push and pull using SSH:
git push origin main
git pull origin main