C.W.K.
Stream
Lesson 03 of 12 · published

SSH Key Pairs

~15 min · public-key, private-key, asymmetric-crypto, ed25519

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

Asymmetric crypto, in one image

SSH keys come in pairs: a private key and a public key, mathematically linked. Think of the public key as a padlock you mail to anyone — they can lock things with it but can't unlock. The private key is the only key that opens those padlocks, and it never leaves your machine.

How auth actually works

  1. The server has your public key in ~/.ssh/authorized_keys.
  2. You connect. The server generates a random challenge and signs it with the algorithm parameters tied to your public key.
  3. Your client signs the challenge with your private key and returns the signature.
  4. The server verifies the signature with the public key. If it matches, you're in.

Crucially, the private key never crosses the wire. The server never sees it. The challenge-response mechanism proves you have it without disclosing it.

Why keys beat passwords

  • Strength — A 256-bit ed25519 key is astronomically harder to brute-force than any password.
  • No transmission — Nothing secret ever travels.
  • No reuse — Each device has its own key. One device compromised doesn't mean others are.
  • Revocable per device — Remove one line from authorized_keys to revoke one device.
  • Automation-friendly — Cron, CI, scripts authenticate without a stored password.

Code

Look at a key pair·bash
# Generate a key pair (full lesson is next — for now just look)
ls -la ~/.ssh/

# Public key — this is what goes on servers
cat ~/.ssh/id_ed25519.pub
# Format: <type> <base64-key> <comment>
# ssh-ed25519 AAAAC3...  you_username@macbook

# Private key — NEVER cat or share this
file ~/.ssh/id_ed25519
# Should be: OpenSSH private key

External links

Exercise

If you don't already have a key, peek into ~/.ssh/. If you do have one, run cat ~/.ssh/id_ed25519.pub and identify the three parts of the line: type, base64-encoded key, and comment. The comment is your only way to remember which device a key belongs to once it lands on a server — make it descriptive when you generate one in the next lesson.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.