Back to the command reference

ssh-keygen

NetworkFundamentals In real Linux

Generate SSH key pairs

Name: ssh-keygen = SSH key generator

This command needs a real Linux system; you can practise it in real Linux mode.

Description

ssh-keygen creates SSH key pairs. The private key (e.g. ~/.ssh/id_ed25519) stays secret; the public key (ending .pub) goes into a server's ~/.ssh/authorized_keys for password-less logins.

Syntax

ssh-keygen [OPTION]...

Common options

-t TYPEKey type; ed25519 is recommended
-b BITSKey size (4096 is common for RSA; not needed for ed25519)
-C COMMENTComment, usually an email
-f FILEOutput file
-N PASSPHRASEThe passphrase for the new key (-N "" for none)
-pChange the passphrase of an existing key
-lShow the key’s fingerprint
-yPrint the public key of a private key
-R HOSTRemove a host from known_hosts (when its key changed)

Examples

Related