The ssh-keygen(1) man page documents every flag and option for the key generation tool. The right way to read it is to focus on the section you need (key type, key bits, output file, comment, passphrase) and to use the examples at the bottom of the page. The team that knows how to navigate this man page has the answer to any ssh-keygen question without leaving the terminal.
Table of contents
- Reading the man page
- The right key type flag
- The bits flag
- The comment flag
- The output file flag
- The passphrase flags
- The advanced flags
- FAQ
Reading the man page
The right command is man ssh-keygen. The page is divided into sections: NAME, SYNOPSIS, DESCRIPTION, OPTIONS, FILES, AUTHORS, and SEE ALSO. The right way to read it is to start with SYNOPSIS to see the command structure, then OPTIONS for the flag reference, then the bottom of the page for examples.
The right way to search within the man page is /keyword. For example, /ed25519 jumps to the ed25519 section. The right keyboard shortcuts are n for next match, N for previous match, q to quit, and h for help.
The right key type flag
The -t flag is the key type. The right answer for new keys in 2026 is ed25519:
ssh-keygen -t ed25519
The right answer for legacy systems that do not support Ed25519 is rsa:
ssh-keygen -t rsa -b 4096
The right answer for ECDSA is -t ecdsa -b 521. The wrong answer is to use DSA (-t dsa), which is deprecated and no longer generated by default in OpenSSH 7.0+.
The bits flag
The -b flag is the key bits. The right answer is to omit it for ed25519 (the algorithm fixes the size at 256 bits). The right answer for RSA is 4096 bits for new keys, 2048 for legacy systems that do not support larger keys. The wrong answer is 1024-bit RSA, which is considered insecure.
ssh-keygen -t rsa -b 4096
The right answer for ECDSA is 256, 384, or 521. The wrong answer is 192, which is too small.
The comment flag
The -C flag is a comment that goes into the public key. The right answer is to set it to your email or a description of the workstation. The right answer is to set the comment when generating the key:
ssh-keygen -t ed25519 -C "alice@laptop"
The wrong answer is to leave the comment blank — a blank comment makes the key hard to identify in authorized_keys on the server.
The output file flag
The -f flag is the output file. The right answer is to use the default (~/.ssh/id_<type>) unless you have a specific reason. The right answer for a custom file is to use the -f flag and to set up ~/.ssh/config with the right IdentityFile:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_github -C "alice@github"
Host github.com
IdentityFile ~/.ssh/id_ed25519_github
IdentitiesOnly yes
The passphrase flags
The -N flag is the new passphrase. The -P flag is the old passphrase (used when changing a passphrase with -p). The right answer is to set a passphrase at generation time:
ssh-keygen -t ed25519 -N "passphrase-here"
The right answer is to use ssh-agent to avoid retyping the passphrase. The wrong answer is to use an empty passphrase (-N "") — that removes the protection of the key.
The right answer to change a passphrase on an existing key is -p:
ssh-keygen -p -f ~/.ssh/id_ed25519
This prompts for the old passphrase and then the new one.
The advanced flags
The right answer for a hardware-backed key (YubiKey, smart card) is -t ed25519-sk:
ssh-keygen -t ed25519-sk -O resident -O application=ssh:alice@laptop
The -sk suffix is for security keys. The resident flag stores the key on the device. The wrong answer is to use a regular Ed25519 key for high-value use cases — the right answer is a hardware-backed key.
The right answer for an OpenSSH format key is the default (no flag needed). The right answer for a legacy PEM format is -m PEM:
ssh-keygen -t rsa -b 4096 -m PEM
The wrong answer is to use PEM format for new keys — OpenSSH format is the default and is what current ssh clients expect.
FAQ
What is the recommended key type in 2026?
Ed25519. The right answer for new keys is ssh-keygen -t ed25519. The wrong answer is to use RSA for new keys — the right answer is RSA only for legacy compatibility.
What is the default key type if -t is not specified?
OpenSSH 7.0+ default is RSA, but most distros have changed the default in their ssh-keygen. The right answer is to always specify -t explicitly. The wrong answer is to assume the default is what you want.
What does -b 4096 do for RSA?
It sets the key size to 4096 bits. The right answer for new RSA keys is 4096. The wrong answer is 1024 or 2048 — 1024 is insecure, 2048 is the minimum acceptable for new RSA keys.
What is the difference between -N and -p?
-N sets the new passphrase at key generation. -p changes the passphrase of an existing key. The right answer for a new key is -N (or interactively). The right answer for an existing key is -p.
How do I see the public key from the private key?
ssh-keygen -y -f ~/.ssh/id_ed25519. This prompts for the passphrase (if any) and prints the public key. The right answer is to use this when you need to re-deploy the public key to a server.
What does the randomart image do?
It is a visual fingerprint of the key. The right answer is to look at it once and remember what it looks like. If the randomart for a host key changes, the right answer is to investigate (possible MITM attack).
What is the -E flag?
The fingerprint hash algorithm. The right answer for the modern usage is -E sha256. The wrong answer is the default MD5, which is deprecated.
Can I generate multiple keys at once?
Not directly, but the right answer is to run ssh-keygen multiple times. The right answer for a script is to loop over the desired key types. The wrong answer is to think one command can generate multiple keys.
What is the -l flag?
It shows the fingerprint of a key file. The right command is ssh-keygen -l -f ~/.ssh/id_ed25519. The right answer is to compare the fingerprint against the expected value to verify the key is what you think it is.
What is the -A flag?
It generates host keys for all the default key types. The right answer is to use this in the sshd init script to generate host keys on first boot. The right answer for a client key is to omit -A.
If you are sizing the infrastructure for the kind of project this post covers, the RunxBuild hosting calculator is the right place to model the line items. The compute, the memory, the storage, the bandwidth, the database - each one is a separate number, and the team’s mental model for the platform is the sum of those numbers. The RunxBuild dashboard is where the team sees the actual usage in one place.
Useful related references: