ssh-keygen

Generate, inspect, and manage SSH public/private key pairs.

low risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

ssh-keygen creates key pairs for passwordless SSH authentication. Ed25519 is the modern standard — shorter, faster, and more secure than RSA. -C adds an identifying comment. -f sets the filename. -R removes stale entries from known_hosts.

Common flags
FlagMeaning
-tKey type: ed25519 (recommended), ecdsa, rsa
-bKey bits — for RSA: minimum 2048, prefer 4096
-CComment to identify the key (typically email or hostname)
-fOutput filename for the key pair
-NPassphrase for the private key ('' for none)
-pChange the passphrase of an existing private key
-lShow fingerprint of a public key file
-RRemove a host entry from ~/.ssh/known_hosts
Examples
ssh-keygen -t ed25519 -C 'deploy@prod' -f ~/.ssh/prod_ed25519Generate a named Ed25519 key pair for production deployment · explain & risk-check →
ssh-keygen -t rsa -b 4096 -C '[email protected]'Generate a 4096-bit RSA key for legacy system compatibility · explain & risk-check →
ssh-keygen -l -f ~/.ssh/id_ed25519.pubDisplay the fingerprint of a public key for verification · explain & risk-check →
Pro tip

Always prefer Ed25519: `ssh-keygen -t ed25519` — the public key is 68 characters vs 800+ for RSA-4096, with stronger security properties.

Related
ssh-copy-id ssh openssl gpg age
Open the full explainer →More in Users, Permissions & Security

Reference text is hand-written and may be incomplete — check man ssh-keygen for your version. Test destructive commands on a non-production system first.