How-To

SSH & GitHub Keys

SSH keys are used for Git operations (cloning/pushing) and secure shell access. They are not the same as OpenPGP keys (which you use for encrypted email). This page walks you through creating an SSH key, adding it to GitHub, and testing it.

Recommended choice

Table of contents

1) Generate a key

Run this once on each device. It creates a private key (keep secret) and a public key (safe to share).

Windows 11 (PowerShell)
  1. Open PowerShell.
  2. Run:
ssh-keygen -t ed25519 -a 64 -C "your_email@example.com"
  • Press Enter to accept the default file location.
  • Set a passphrase when asked (recommended).
  • Your keys are typically saved in: $env:USERPROFILE\.ssh\
Linux / macOS (Terminal)
ssh-keygen -t ed25519 -a 64 -C "your_email@example.com"

Keys are typically saved in: ~/.ssh/

Public vs private key
  • Public key ends in .pub (example: id_ed25519.pub)
  • Private key has no extension (example: id_ed25519)

Never share your private key.

2) Add it to the SSH agent

The agent holds decrypted keys in memory so you don’t type your passphrase constantly.

Windows 11 (PowerShell)

Open PowerShell as Administrator to configure and start the SSH agent service (the first two commands). Once the service is running, use a normal PowerShell window to add your key.

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
Linux / macOS
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

3) Add it to GitHub

  1. Copy your public key text (the .pub file).
  2. In GitHub: Settings → SSH and GPG keys → New SSH key.
  3. Give it a title (example: “Desktop - Windows 11”), paste the key, and save.
Copy your public key

Windows (PowerShell):

type $env:USERPROFILE\.ssh\id_ed25519.pub

Linux / macOS:

cat ~/.ssh/id_ed25519.pub

4) Test the connection

The first time, you may be asked to trust GitHub’s host key (normal). Before accepting it, compare the fingerprint shown with the ones published in GitHub’s official documentation.

ssh -T git@github.com
If you get “Permission denied (publickey).”
  • Make sure your key is added in GitHub settings.
  • Make sure the key is loaded in the agent: ssh-add -l
  • Confirm you are using the right key file (especially if you have multiple).

5) Practical tips

Multiple GitHub accounts / multiple keys

Use host aliases in ~/.ssh/config:

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519

Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work

Then clone with: git@github-work:ORG/REPO.git

Backups and safety
  • Back up your private key only if you can store it securely.
  • If a private key is exposed, generate a new one and remove the old one from GitHub.
  • Passphrase + agent gives strong day-to-day protection.