Git & GitHub · SSH Setup

Add your SSH key
to GitHub

Copy your public key from Task 1, register it with GitHub, test the connection, and push without a password — ever again.

Prereq: SSH keypair generated (Task 1)
Time: ~5 minutes
OS: macOS / Linux / WSL
01 — Required

Copy your public key

Print your public key to the terminal and copy the entire output — from ssh-ed25519 (or ssh-rsa) all the way to the trailing email comment.

$ cat ~/.ssh/id_ed25519.pub
Output looks like: ssh-ed25519 AAAA...XYZ you@machine. Select and copy the whole line — including the email at the end.
! Only copy the .pub file. Your private key (id_ed25519) must never leave your machine.
02 —

Open GitHub SSH settings

Log in to GitHub, then navigate to your SSH key management page. You can follow the menu path or go directly via URL:

https://github.com/settings/keys
03 —

Add the new SSH key

On the SSH and GPG keys page, click New SSH key. Fill in the form:

# Title — something memorable
Title: Work MacBook Pro
 
# Key type — leave as default
Key type: Authentication Key
 
# Key — paste your public key here
Key: ssh-ed25519 AAAA... you@machine

Then click Add SSH key and confirm with your GitHub password if prompted.

Use a descriptive title that identifies the machine — you may add multiple keys (laptop, desktop, server) and will want to tell them apart.
04 — Verify

Test the connection

Back in your terminal, run the SSH test command. This authenticates to GitHub's endpoint and confirms your key is recognised — without granting any shell access.

$ ssh -T git@github.com

If prompted about the host fingerprint, type yes to trust it. You should see:

expected output
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
"Does not provide shell access" is expected — it confirms authentication worked. If you see Permission denied (publickey), double-check that your key was saved correctly in Step 3.
05 — Optional

Clone or switch repos to SSH

Your key is live. Use SSH URLs going forward. To switch an existing repo from HTTPS to SSH:

$ git remote set-url origin git@github.com:user/repo.git

Or clone a new repo with an SSH URL:

$ git clone git@github.com:user/repo.git

Verify the remote is correct with:

$ git remote -v

You're all set

Your machine is trusted by GitHub via SSH. git push, pull, and fetch over SSH will now work without entering a password or personal access token. Add more keys anytime at github.com/settings/keys.