SSH keys explained, and how to manage them well
27 Nov 2026 security ssh
How key pairs work, why they beat passwords and how to keep track of them.
A key pair is two linked files. The public key goes on the server. The private key stays with you. The server asks you to prove you hold the private key without it ever being sent.
Why it beats a password
There is nothing short to guess, nothing reused from another site, and nothing the server can leak that lets someone sign in.
Make one
ssh-keygen -t ed25519 -C "asha@laptop"
Set a passphrase. It protects the file if your laptop is stolen. An agent remembers it for the session:
ssh-add ~/.ssh/id_ed25519
One key per person per device
Never share a private key between people. With separate keys you can remove one person without disturbing the rest.
Keep a register
Note whose each key is, where it is installed and when to review it. The comment at the end of a public key helps.
Automation
Give scripts their own key, restrict it in authorized_keys, and allow only the command needed:
restrict,command="/usr/local/bin/backup-send" ssh-ed25519 AAAA... backup-job
If a key is exposed
Remove its public key everywhere, create a new pair, and review sign-in logs.
Start with creating and adding a key.