How an SSH key pair logs you into a server: a private key stays on your laptop while a public key checks a signed puzzle.
Your laptop wants to log in to a server, a computer far away that stores and runs things. SSH is the safe way they talk. Instead of a password, it can use a matching pair of keys. Drag to turn the scene and look around.
SSH stands for Secure Shell.
A program called ssh-keygen makes two files at once: a private key and a public key. They are linked by maths, like a key and the one padlock it fits. Press Make keys to watch the pair appear.
A modern Ed25519 key is only 32 bytes, shorter than this sentence.
The private key lives in a hidden folder called .ssh on your laptop, and it never leaves. A passphrase, a secret phrase only you know, can lock it like the dial on this box.
The public key is one short line of text: the key type, a long code and a name tag. Sharing it is safe. The server keeps it in a list called authorized_keys, like hanging your padlock on its door.
Every Ed25519 public key begins with the same letters: AAAAC3NzaC1lZDI1NTE5.
When you connect, the server makes a fresh puzzle just for this visit and sends it across. Only the matching private key can answer it. Press Connect and watch the puzzle travel.
Your laptop uses the private key to sign the puzzle, like pressing a stamp nobody else owns. Only the stamped answer travels back. The private key itself never crosses the wire.
An Ed25519 signature is 64 bytes.
The server checks the stamp with your public key. A public key can check a stamp, but it can never make one. The match is right, so the lock opens and you are logged in.
Guessing a private key by trying would take far longer than the age of the universe. Your laptop also remembers each server's own key in a file called known_hosts, so it can spot an impostor. Keep the private key secret and share the public key freely.
A passphrase cannot be recovered. If you forget it, make a new key pair.