This guide will show you how to generate OpenSSH keys on Linux.
Prerequisites
Make sure you have the openssh-server
package installed.
|
|
Generate OpenSSH Key
To generate an OpenSSH key:
|
|
This will prompt you for a passphrase (you can leave it blank if you don’t want to use one), ask you for the location of the key file, and then generate a private key (default id_rsa
) and a public key file (default id_rsa.pub
).
Generate OpenSSH Key of a specific length
-b
flag specifies the number of bits in the key to create. For RSA keys, the minimum size is 1024 bits and the default is 3072 bits. Generally, 3072 bits is considered sufficient. For ECDSA keys, the -b flag determines the key length by selecting from one of three elliptic curve sizes: 256, 384 or 521 bits. Attempting to use bit lengths other than these three values for ECDSA keys will fail. ECDSA-SK, Ed25519 and Ed25519-SK keys have a fixed length and the -b flag will be ignored.
To generate an OpenSSH key of a specific length:
|
|
This will generate a private key file id_rsa
and a public key file id_rsa.pub
.