Network and remote access

Command ssh-keygen

Create and manage SSH-options

Linux · Bash examples · commands run on the selected server

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 authorisation.

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

-t TYPE
Key type, for example ed25519.
-f PATH
The name of the key file or key to process.
-l
Show key fingerprint; -F searches for node in known_hosts.

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.pub

The public key's fingerprint is displayed for trusted comparison.

Find a known server entry

ssh-keygen -F server.example.com

Existing 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 authorisation request.

Will generating a key automatically grant server access?

No. The public key must be authorised 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.