Github SSH Setup
SSH authentication setup for github
1. Generate a New SSH Key
Use a label related to GitHub, like id_ed25519_github
.
ssh-keygen -t ed25519 -C "john@example-mail.com"
- Save it as:
~/.ssh/id_ed25519_github
- Set a passphrase (optional but recommended)
2. Add SSH Key to SSH Agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_github
3. Add SSH Key to GitHub
cat ~/.ssh/id_ed25519_github.pub
Copy the output.
Then:
- Go to GitHub SSH Settings
- Paste the public key
- Give it a meaningful title:
laptop-id_ed25519_github
PART 2: Set Up Git to Use SSH
In your project (or globally)
git config --global user.name "Your Name"
git config --global user.email "your_username@users.noreply.github.com"
Replace
your_username
with your actual GitHub username.
To hide your real email, make sure:
- You use your GitHub noreply email
- You enable "Keep my email address private" on GitHub:
- https://github.com/settings/emails → ✔️ Keep my email address private
PART 3: Ensure GitHub Uses SSH (Not HTTPS)
Change remote URL to use SSH:
git remote set-url origin git@github.com:john/john-repo-name.git
PART 4: Test SSH Connection
ssh -T git@github.com
Expected output:
Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
How to solve dev.zed.Zed flatpak app ssh connection issue?
This also works for multiple accounts like personal-work
nano ~/.ssh/config
Add:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github