DEV Community

Adam Johnson
Adam Johnson

Posted on

Faced a Problem Cloning a Private Repo? Here’s How I Connected GitHub with SSH

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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

Replace "email@example.com" with the email address linked to your GitHub account.

ssh-keygen -t rsa -b 4096 -C "email@example.com"
Enter fullscreen mode Exit fullscreen mode

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):
Enter fullscreen mode Exit fullscreen mode

Simply press Enter to accept the default location.

Enter passphrase (empty for no passphrase):
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode

If successful, you’ll see:

Hi username! You've successfully authenticated...
Enter fullscreen mode Exit fullscreen mode

That means your SSH setup works perfectly!

Clone Your Private Repository via SSH

git clone git@github.com:username/repo.git
Enter fullscreen mode Exit fullscreen mode

Replace username and repo.git with your actual GitHub username and repository name.

Top comments (0)