ssh-keygen

authentication key generation, management and conversion

ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment] [-f output_keyfile]
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
ssh-keygen -i|e [-f keyfile]
(import|export)

ssh-keygen -y [-f keyfile] (yank private OpenSSH, output public key)
ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]

ssh-keygen -l [-f keyfile]
(list fingerprint)
ssh-keygen -B [-f keyfile]
(show bubblebabble)
ssh-keygen -F hostname [-f known_hosts_file] [-l]
(find host)

ssh-keygen -H [-f known_hosts_file]
(hash it)
ssh-keygen -R hostname [-f known_hosts_file]
(remove host)
ssh-keygen -D|U reader
download|Upload to reader
ssh-keygen -r hostname [-f input_keyfile] [-g]
(reveal fingerprint)

Generates, manages and converts authentication keys for ssh.

Creates RSA keys protocol version 1 and RSA or DSA keys for version 2 as specified with -t default RSA

Generates groups for use in Diffie-Hellman group exchange (DH-GEX).

Generates host keys for /etc/rc.

Users runs this to create their authentication key . With SSH keys, if someone gains access to your computer, they also gain access to every system that uses that key.
To add an extra layer of security, you can add a passphrase to your SSH key.
You can use ssh-agent to securely save your passphrase so you don't have to reenter it. Passphrase may be a string of arbitrary length, changed using -p. Similar to a password can be a phrase of words, punctuation, numbers, whitespace, or any string.

For RSA1 keys a comment field to the user to help identify the key, changed using -c .

-t RSA|DSA RSA vs DSA (when in doubt pick DSA IMHO ) Digital Signature Algorithm vs Ron Rivest, Adi Shamir, and Leonard Adleman.
-b bits number of bits in the key For RSA minimum 768 and default: 2048 bits. DSA 1024
-C comment RSA1
-cchange comment
-D reader
-U reader
Download the RSA public key to a smartcard in reader.
Upload an existing RSA private key into the smartcard in reader.
-e export key in RFC 4716 SSH Public Key File Format to stdout
-F hostname Find hostname in known_hosts Useful to find hashed host names or addresses and may also be used with -H
-H Hash known_hosts the original is moved to .old .
-R hostname Removes keys from known_hosts file useful to delete hashed hosts
-i Reads an unencrypted private key file or RFC4716 Public Key and outputs an OpenSSH to stdout.
-f filename key file.
-l list fingerprint of specified public key file.
With -v, an ASCII art representation of the key output:
-B file Show the bubblebabble digest
-p file Requests changing the passphrase of a private key file instead of creating a new private key. Prompts for the file containing the private key, for the old passphrase, and twice for the new passphrase.
-N new‑passphrase
-P current passphrase
-q quite (Used by /etc/rc when creating a new key.)
-r hostname reveal the SSHFP fingerprint resource record named hostname for the specified public key file. Default .ssh/id_rsa
-g Use generic DNS format when outputing fingerprint resource records using -r
-y read a private file and output public key to stdout.

 > ssh-keygen    
Generating public/private rsa key pair.
Enter file in which to save the key (/Volumes/DATA/dgerman/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Volumes/DATA/dgerman/.ssh/id_rsa.
Your public key has been saved in /Volumes/DATA/dgerman/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:oTvL+IaG8Hpe1D862lBRr7RMsqfEZtMaUymJVX/OLdY dgerman@smacpro
The key's randomart image is:
+---[RSA 2048]----+
|      ..o        |
|     o o +       |
|    . = * o .    |
|     o % + + o   |
|    . & S   = E  |
|.  . = X   . .   |
| . o..= o        |
|  +.==o+ .       |
|.+..o+*.         |
+----[SHA256]-----+

> ssh-keygen -B
Enter file in which the key is (/Volumes/DATA/dgerman/.ssh/id_rsa): 
2048 xugel-tymes-mopal-vyzoz-xxxxx-yyyyy-zzzzz-fucyc-kehip-nelef-vuxyx username@clienthost (RSA) 

> sh-keygen -l
Enter file in which the key is (/Volumes/DATA/dgerman/.ssh/id_rsa): 
2048 SHA256:oTvL+xxxxxxxxxx62yyyyyyyyyyEZtMaUymJVX/OLdY username@clienthost (RSA)/pre>

FILES

~/.ssh/identity version 1 RSA authentication identity of the user. Must be not be readable by by group or others. It is possible to specify a passphrase when generating the key which is used to encrypt the private part using 3DES. Not automatically accessed by ssh-keygen but is the default file for the private key. Read by ssh at login
~/.ssh/identity.pub version 1 RSA public key
. Add to ~/.ssh/authorized_keys
~/.ssh/id_dsa version 2 DSA authentication identity of the user. Must be not be readable by by group or others. It is possible to specify a passphrase when generating the key is used to encrypt the private part of this file using 3DES. Not automatically accessed by ssh-keygen but default is the file for the private key. Read by ssh at login made.
~/.ssh/id_dsa.pub version 2 DSA public key.
Add to ~/.ssh/authorized_keys
~/.ssh/id_rsa version 2 RSA authentication identity of the user. Must be not be readable by by group or others. A passphrase when generating the key used to encrypt the private part of this file using 3DES. Not automatically accessed by ssh-keygen default file for the private key. Read by ssh at login made.
~/.ssh/id_rsa.pub version 2 RSA public key . Added to ~/.ssh/authorized_keys
/etc/ssh/moduli for DH-GEX. See moduli

ssh-agent

SEE ALSO

ssh(1), ssh-add(1), ssh-agent(1), moduli(5), sshd(8)

The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006.