Check for existing SSH keys
Before generating anything new, check if you already have a key pair sitting in ~/.ssh. If you see files like id_ed25519.pub or id_rsa.pub, you can skip straight to Step 3.
ls -al ~/.ssh
Generate a new ed25519 key
Use ed25519 — it's faster and more secure than the older RSA approach. Swap in the email address tied to your GitHub account.
ssh-keygen -t ed25519 -C "you@example.com"
When prompted:
# Press Enter to accept the default location (~/.ssh/id_ed25519)
Enter file in which to save the key:
# Add a passphrase (recommended) or press Enter to skip
Enter passphrase (empty for no passphrase):
Add the key to ssh-agent
The agent holds your key in memory so you don't re-enter the passphrase on every git push. Start it, then register the key.
# Start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Register your private key
ssh-add ~/.ssh/id_ed25519
systemctl --user enable --now ssh-agent, then add export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" to your ~/.bashrc.
Copy your public key
Print the public key to your terminal, then copy it to your clipboard. Only ever share the .pub file — the private key never leaves your machine.
cat ~/.ssh/id_ed25519.pub
# Or pipe straight to clipboard with xclip / xsel
cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard
If xclip isn't installed: sudo dnf install xclip -y
Add the key to GitHub
Head to GitHub in your browser and navigate to:
github.com → Settings → SSH and GPG keys → New SSH key
Paste your public key into the Key field. Give it a recognisable title (e.g. fedora43-laptop). Leave the key type as Authentication Key, then click Add SSH key.
ssh-ed25519 and end with your email.
Test the connection
One command confirms everything is wired up correctly:
ssh -T git@github.com
Expected output:
Hi username! You've successfully authenticated,
but GitHub does not provide shell access.
If you see that message, you're done. All git operations using SSH URLs will now authenticate silently.
git remote set-url origin git@github.com:USER/REPO.git
Configure ~/.ssh/config for multiple accounts
If you use multiple GitHub accounts (personal + work), create a config file to map different hostnames to different keys:
# Personal account
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
# Work account
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
Then clone work repos with: git clone git@github-work:ORG/REPO.git
The whole thing in one block
# 1. Generate key
ssh-keygen -t ed25519 -C "you@example.com"
# 2. Start agent + add key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# 3. Copy public key (install xclip first if needed)
sudo dnf install xclip -y
cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard
# 4. Paste into github.com → Settings → SSH keys
# 5. Test
ssh -T git@github.com