ssh-keygen
Generate key pairs, inspect fingerprints and change a private key’s passphrase.
Before you run
Enter a strong passphrase at the prompt. The .pub file is public; the file without .pub is private and must never be uploaded to the server or shared. If the destination key already exists, do not overwrite it unintentionally. Changing the passphrase changes private-key protection, not your server password. Ed25519 availability depends on the server and security policy.
Examples
Create an Ed25519 key pair; prompts let you set a passphrase.
ssh-keygen -t ed25519 -C 'laptop-key' -f ~/.ssh/id_ed25519Display the public key’s fingerprint for comparison.
ssh-keygen -lf ~/.ssh/id_ed25519.pubChange the existing private key’s passphrase interactively.
ssh-keygen -p -f ~/.ssh/id_ed25519Options and examples
-t typeCommonChoose the key type; ed25519 is a common choice when supported by both sides.
ssh-keygen -t ed25519-f filenameCommonSpecify the key file. Check the path before creating a key to avoid overwriting an existing key.
ssh-keygen -t ed25519 -f ~/.ssh/lab_key-C commentCommonAdd a comment to a generated key for identification.
ssh-keygen -t ed25519 -C 'laptop-key'-b bitsSpecify key size for algorithms that support it, such as RSA.
ssh-keygen -t rsa -b 4096-a roundsSet the key derivation rounds used to protect a private key with a passphrase.
ssh-keygen -t ed25519 -a 64-l -f filenameCommonShow the fingerprint of a key or known-hosts entry.
ssh-keygen -lf ~/.ssh/id_ed25519.pub-p -f filenameCommonChange the passphrase of an existing private key interactively.
ssh-keygen -p -f ~/.ssh/id_ed25519-y -f filenamePrint the public key derived from a private key.
ssh-keygen -y -f ~/.ssh/id_ed25519-F hostnameFind a host in the known_hosts file, including hashed entries.
ssh-keygen -F server.example.com-R hostnameRemove matching entries from known_hosts. Verify a replacement host key independently before trusting it.
ssh-keygen -R server.example.comAuthoritative references
Reviewed October 27, 2026