I once ran into an issue cloning a private repo and got tired of typing my GitHub username and password every time I pushed or pulled changes.
So, I decided to set up SSH authentication, a simple and secure way to connect to GitHub without those annoying password prompts.
Check if You Already Have an SSH Key
ls ~/.ssh/id_*.pub
If you see files like id_ed25519.pub or id_rsa.pub, you already have an SSH key pair.
If not, proceed to generate one.
Generate a New SSH Key
ssh-keygen -t ed25519 -C "email@example.com"
Replace "email@example.com" with the email address linked to your GitHub account.
ssh-keygen -t rsa -b 4096 -C "email@example.com"
If your system doesn’t support ed25519, you can use rsa -b 4096.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):
Simply press Enter to accept the default location.
Enter passphrase (empty for no passphrase):
Set a Passphrase (Optional)
You can either:
- Press Enter to leave it empty (no password)
- Or add a passphrase for extra security
Add Your SSH Key to GitHub
cat ~/.ssh/id_ed25519.pub
- Copy the entire output
- Go to GitHub → Settings → SSH and GPG keys
- Click “New SSH key”
- Paste your key into the Key field
- Give it a Title (e.g., “Fedora Laptop”)
- Click Add SSH key
Test the SSH Connection
ssh -T git@github.com
If successful, you’ll see:
Hi username! You've successfully authenticated...
That means your SSH setup works perfectly!
Clone Your Private Repository via SSH
git clone git@github.com:username/repo.git
Replace username and repo.git with your actual GitHub username and repository name.
Top comments (0)