DEV Community

Kb Bohara
Kb Bohara

Posted on

1 1 1 1 1

SSH for GitHub Baby

Check for Existing SSH Keys

ls -al ~/.ssh
Enter fullscreen mode Exit fullscreen mode

Generate a New SSH Key

If no keys are found, generate one:

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

Start the SSH Agent (optional)

Why?: The agent manages your keys and prevents you from entering your passphrase every time.

eval "$(ssh-agent -s)"
Enter fullscreen mode Exit fullscreen mode

Add SSH Key to Agent

ssh-add ~/.ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode

Copy the SSH Public Key

cat ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

Add the Key to GitHub

  • Go to GitHub > Settings > SSH and GPG keys > New SSH key.
  • Paste the copied key.

Test SSH Connection

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

Update Git Remote URL

git remote set-url origin git@github.com:uname/repo.git
Enter fullscreen mode Exit fullscreen mode

Done! You're all set to use SSH with GitHub!

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →