When to use ssh-keygen
Use ssh-keygen to create or inspect SSH key material. Keep the private key private, protect it with a passphrase where appropriate and distribute only the public key for account authorization.
Syntax
ssh-keygen [PARAMETERS]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Create a separate key with an interactive passphrase
ssh-keygen -t ed25519 -f ~/.ssh/terminalus_demo -C 'terminalus-demo'A new key pair is created at the selected path; inspect any overwrite prompt and choose a suitable passphrase.
Verify public key fingerprint
ssh-keygen -lf ~/.ssh/terminalus_demo.pubThe public key's fingerprint is displayed for trusted comparison.
Find a known server entry
ssh-keygen -F server.example.comExisting known-host records matching the server name are inspected without removing them.
Notes and limitations
- The private key is the file without .pub. Only send the public key to the server.
- Back up an existing key before replacing it. Removing a known_hosts entry does not replace verifying the new fingerprint.
Common questions and troubleshooting
Which file can I copy to the server administrator?
Share the public key file, normally ending in .pub. Never send the paired private key or its passphrase as an authorization request.
Will generating a key automatically grant server access?
No. The public key must be authorized for the intended server account, and the SSH server's authentication policy must permit it.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man ssh-keygen.