ssh-keygen

SSH-Keygen is a Unix utility that is used to generate, manage, and convert authentication keys for ssh authentication. With the help of the SSH-Keygen tool, a user can create passphrase keys for both SSH protocol version 1 and version 2. SSH-keygen creates RSA keys for SSH protocol version 1 and RSA or DSA keys for use by SSH protocol version 2.

Contents

Working

The SSH-keygen tool stores the private key in $HOME/.ssh/id_rsa and the public key in $HOME/.ssh/id_rsa.pub in the user’s home directory. The user should then copy the id_rsa.pub to $HOME/.ssh/authorized_keys in his home directory on the remote machine. It also asks for a passphrase. The passphrase may be empty to indicate no passphrase (host keys must have an empty passphrase), or it may be a string of arbitrary length. Instead of RSA, DSA can also be used. The steps to create authorization keys by using the SSH-keygen tool are as follows:

[axl@asterisk1 axl]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
...
Enter file in which to save the key (/home/axl/.ssh/id_rsa): <return>
Enter passphrase (empty for no passphrase): <Type the passphrase>

Enter same passphrase again: <Type the passphrase>
Your identification has been saved in /home/axl/.ssh/id_rsa.
Your public key has been saved in /home/axl/.ssh/id_rsa.pub.
The key fingerprint is:
0b:fa:3c:b8:73:71:bf:58:57:eb:2a:2b:8c:2f:4e:37 axl@myLocalHost

ssh-keygen command syntax

The syntax of the ssh-keygen file is as follows:

ssh-keygen [options]

Some of the important options of ssh-keygen command are as follows:

ssh-keygen command options description
-b bits Specifies the number of bits in the key to create. The minimum bit length is 768 bits and the default length is 2048 bits.
-p Requests changing the passphrase of a private key file instead of creating a new private key.
-t Specifies the type of key to create.
-q quiets ssh-keygen. It is used by the /etc/rc file while creating a new key.
-N Provides a new Passphrase.
-F For ssh-keygen2, dumps the key's fingerprint in Bubble Babble format

Files Used by SSH-Keygen utility

The SSH-Keygen utility uses various files for storing public and private keys. The files used by SSH-Keygen utility are as follows:

External links