GitHub SSH Key Setup Guide

This guide provides a clear, step-by-step workflow to generate, register, and use SSH keys with GitHub for secure passwordless authentication.


๐Ÿ” 1. Check Existing SSH Keys

Before creating a new key, check whether your system already has one:

ls ~/.ssh

If you see files like:

  • id_rsa / id_rsa.pub

  • id_ed25519 / id_ed25519.pub

You already have SSH keys.


๐Ÿ— 2. Generate a New SSH Key

GitHub recommends the modern ed25519 algorithm:

ssh-keygen -t ed25519 -C "your_email@example.com"

Press Enter to accept defaults.

Your keys will be saved to:

  • ~/.ssh/id_ed25519

  • ~/.ssh/id_ed25519.pub


๐Ÿ”ง 3. Start the SSH Agent

Make sure the agent is running:

Add your private key:


๐Ÿ“‹ 4. Add Public Key to GitHub

Copy the contents of your public key:

Go to: GitHub โ†’ Settings โ†’ SSH and GPG Keys โ†’ New SSH Key

Paste the key content.


๐Ÿ›ฐ 5. Verify SSH Authentication

Test connection:

Success message:


๐Ÿ”„ 6. Convert Repository Remote URL to SSH

If your repo is using HTTPS, change it:

Check result:


๐Ÿš€ 7. Push Using SSH

Now pushing won't require a username or password:


๐Ÿงฐ Optional: SSH Config for Multiple Keys

Create or edit config file:

Example setup:


โœ… Summary

With SSH keys set up, you can:

  • Push & pull without typing username/password

  • Securely authenticate to GitHub

  • Use multiple repos and accounts smoothly

Your Git workflow becomes faster and more secure.


If you'd like, I can also add:

  • Windows + WSL2 SSH setup

  • Multi-account GitHub SSH setup

  • Auto script to convert all local repos to SSH URLs.

Last updated