ssh-keygen.0 revision 189006
11195SrgrimesSSH-KEYGEN(1)              OpenBSD Reference Manual              SSH-KEYGEN(1)
250472Speter
337SrgrimesNAME
473251Sgshapiro     ssh-keygen - authentication key generation, management and conversion
538103Speter
673251SgshapiroSYNOPSIS
738103Speter     ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment]
864618Sgshapiro                [-f output_keyfile]
955230Speter     ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
1055230Speter     ssh-keygen -i [-f input_keyfile]
1165532Snectar     ssh-keygen -e [-f input_keyfile]
1255230Speter     ssh-keygen -y [-f input_keyfile]
1374462Salfred     ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]
1459257Siwasaki     ssh-keygen -l [-f input_keyfile]
1557954Sshin     ssh-keygen -B [-f input_keyfile]
1667929Sume     ssh-keygen -D reader
1767929Sume     ssh-keygen -F hostname [-f known_hosts_file] [-l]
1870856Sjhb     ssh-keygen -H [-f known_hosts_file]
1970856Sjhb     ssh-keygen -R hostname [-f known_hosts_file]
2055230Speter     ssh-keygen -U reader [-f input_keyfile]
2155230Speter     ssh-keygen -r hostname [-f input_keyfile] [-g]
2255230Speter     ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point]
231734Sjkh     ssh-keygen -T output_file -f input_file [-v] [-a num_trials] [-W
2417639Swosch                generator]
2517639Swosch
2637SrgrimesDESCRIPTION
2757479Speter     ssh-keygen generates, manages and converts authentication keys for
2857488Speter     ssh(1).  ssh-keygen can create RSA keys for use by SSH protocol version 1
2957459Smarkm     and RSA or DSA keys for use by SSH protocol version 2.  The type of key
3057459Smarkm     to be generated is specified with the -t option.  If invoked without any
3157459Smarkm     arguments, ssh-keygen will generate an RSA key for use in SSH protocol 2
3260677Skris     connections.
3360677Skris
3460677Skris     ssh-keygen is also used to generate groups for use in Diffie-Hellman
3560677Skris     group exchange (DH-GEX).  See the MODULI GENERATION section for details.
361773Sjkh
3748734Siwasaki     Normally each user wishing to use SSH with RSA or DSA authentication runs
38147Srgrimes     this once to create the authentication key in ~/.ssh/identity,
3927487Sasami     ~/.ssh/id_dsa or ~/.ssh/id_rsa.  Additionally, the system administrator
4065168Sasami     may use this to generate host keys, as seen in /etc/rc.
4135832Sache
4243901Sbrian     Normally this program generates the key and asks for a file in which to
4349110Sbrian     store the private key.  The public key is stored in a file with the same
4464598Sgshapiro     name but ``.pub'' appended.  The program also asks for a passphrase.  The
4564598Sgshapiro     passphrase may be empty to indicate no passphrase (host keys must have an
4637Srgrimes     empty passphrase), or it may be a string of arbitrary length.  A
4717639Swosch     passphrase is similar to a password, except it can be a phrase with a se-
48263Srgrimes     ries of words, punctuation, numbers, whitespace, or any string of charac-
492779Srgrimes     ters you want.  Good passphrases are 10-30 characters long, are not sim-
508857Srgrimes     ple sentences or otherwise easily guessable (English prose has only 1-2
51993Srgrimes     bits of entropy per character, and provides very bad passphrases), and
52263Srgrimes     contain a mix of upper and lowercase letters, numbers, and non-alphanu-
5338103Speter     meric characters.  The passphrase can be changed later by using the -p
5437Srgrimes     option.
554487Sphk
566717Sphk     There is no way to recover a lost passphrase.  If the passphrase is lost
5739590Sjkh     or forgotten, a new key must be generated and copied to the corresponding
5839636Sdima     public key to other machines.
5939590Sjkh
6039590Sjkh     For RSA1 keys, there is also a comment field in the key file that is only
615948Sjkh     for convenience to the user to help identify the key.  The comment can
624487Sphk     tell what the key is for, or whatever is useful.  The comment is initial-
631759Sjkh     ized to ``user@host'' when the key is created, but can be changed using
649970Sbde     the -c option.
6536902Sguido
6643832Sjkh     After a key is generated, instructions below detail where the keys should
6752609Sdillon     be placed to be activated.
6858979Siwasaki
6961981Sbrian     The options are as follows:
709970Sbde
7151033Sn_hibma     -a trials
729970Sbde             Specifies the number of primality tests to perform when screening
731759Sjkh             DH-GEX candidates using the -T command.
7457488Speter
7557488Speter     -B      Show the bubblebabble digest of specified private or public key
7617639Swosch             file.
7717645Swosch
7857488Speter     -b bits
7974194Sdes             Specifies the number of bits in the key to create.  For RSA keys,
8073251Sgshapiro             the minimum size is 768 bits and the default is 2048 bits.  Gen-
8173251Sgshapiro             erally, 2048 bits is considered sufficient.  DSA keys must be ex-
8273251Sgshapiro             actly 1024 bits as specified by FIPS 186-2.
8367849Sdougb
8467849Sdougb     -C comment
8567849Sdougb             Provides a new comment.
8657488Speter
8757488Speter     -c      Requests changing the comment in the private and public key
8857488Speter             files.  This operation is only supported for RSA1 keys.  The pro-
8957488Speter             gram will prompt for the file containing the private keys, for
9060677Skris             the passphrase if the key has one, and for the new comment.
9160677Skris
9260677Skris     -D reader
9360677Skris             Download the RSA public key stored in the smartcard in reader.
9457071Srwatson
9574194Sdes     -e      This option will read a private or public OpenSSH key file and
9674194Sdes             print the key in RFC 4716 SSH Public Key File Format to stdout.
9757488Speter             This option allows exporting keys for use by several commercial
9857071Srwatson             SSH implementations.
991731Sjkh
1009970Sbde     -F hostname
10137Srgrimes             Search for the specified hostname in a known_hosts file, listing
1029970Sbde             any occurrences found.  This option is useful to find hashed host
10337Srgrimes             names or addresses and may also be used in conjunction with the
1049970Sbde             -H option to print found keys in a hashed format.
10537Srgrimes
1069970Sbde     -f filename
10737Srgrimes             Specifies the filename of the key file.
10837Srgrimes
10937Srgrimes     -G output_file
11037Srgrimes             Generate candidate primes for DH-GEX.  These primes must be
1119970Sbde             screened for safety (using the -T option) before use.
1121731Sjkh
1139970Sbde     -g      Use generic DNS format when printing fingerprint resource records
1141731Sjkh             using the -r command.
1159970Sbde
1166177Samurai     -H      Hash a known_hosts file.  This replaces all hostnames and ad-
11749110Sbrian             dresses with hashed representations within the specified file;
11849110Sbrian             the original content is moved to a file with a .old suffix.
11930589Sjmb             These hashes may be used normally by ssh and sshd, but they do
12064598Sgshapiro             not reveal identifying information should the file's contents be
12164629Sgshapiro             disclosed.  This option will not modify existing hashed hostnames
12264629Sgshapiro             and is therefore safe to use on files that mix hashed and non-
12364629Sgshapiro             hashed names.
12464629Sgshapiro
12564629Sgshapiro     -i      This option will read an unencrypted private (or public) key file
1269970Sbde             in SSH2-compatible format and print an OpenSSH compatible private
12737Srgrimes             (or public) key to stdout.  ssh-keygen also reads the RFC 4716
12863097Speter             SSH Public Key File Format.  This option allows importing keys
129147Srgrimes             from several commercial SSH implementations.
13063097Speter
131147Srgrimes     -l      Show fingerprint of specified public key file.  Private RSA1 keys
13263097Speter             are also supported.  For RSA and DSA keys ssh-keygen tries to
13337Srgrimes             find the matching public key file and prints its fingerprint.  If
13463097Speter             combined with -v, an ASCII art representation of the key is sup-
135288Srgrimes             plied with the fingerprint.
13663097Speter
137147Srgrimes     -M memory
13813378Sache             Specify the amount of memory to use (in megabytes) when generat-
13950126Sgreen             ing candidate moduli for DH-GEX.
14050126Sgreen
14113378Sache     -N new_passphrase
14217104Spst             Provides the new passphrase.
14317104Spst
14463097Speter     -P passphrase
145147Srgrimes             Provides the (old) passphrase.
14663097Speter
14737Srgrimes     -p      Requests changing the passphrase of a private key file instead of
14864665Skris             creating a new private key.  The program will prompt for the file
1491759Sjkh             containing the private key, for the old passphrase, and twice for
1501759Sjkh             the new passphrase.
1519970Sbde
1529970Sbde     -q      Silence ssh-keygen.  Used by /etc/rc when creating a new key.
15361888Sasmodai
1541759Sjkh     -R hostname
15561888Sasmodai             Removes all keys belonging to hostname from a known_hosts file.
15637Srgrimes             This option is useful to delete hashed hosts (see the -H option
157147Srgrimes             above).
15865884Sache
15965884Sache     -r hostname
16065884Sache             Print the SSHFP fingerprint resource record named hostname for
16165884Sache             the specified public key file.
1627129Srgrimes
16365884Sache     -S start
16462416Smarkm             Specify start point (in hex) when generating candidate moduli for
165410Srgrimes             DH-GEX.
16672692Sru
1677129Srgrimes     -T output_file
16811635Sache             Test DH group exchange candidate primes (generated using the -G
16911635Sache             option) for safety.
17011635Sache
17111635Sache     -t type
17211635Sache             Specifies the type of key to create.  The possible values are
17311635Sache             ``rsa1'' for protocol version 1 and ``rsa'' or ``dsa'' for proto-
1747129Srgrimes             col version 2.
17511635Sache
17611635Sache     -U reader
17711635Sache             Upload an existing RSA private key into the smartcard in reader.
17811635Sache
17911635Sache     -v      Verbose mode.  Causes ssh-keygen to print debugging messages
18011635Sache             about its progress.  This is helpful for debugging moduli genera-
18111635Sache             tion.  Multiple -v options increase the verbosity.  The maximum
18211635Sache             is 3.
18311635Sache
18411635Sache     -W generator
185147Srgrimes             Specify desired generator when testing candidate moduli for DH-
18648185Ssheldonh             GEX.
18748185Ssheldonh
18848185Ssheldonh     -y      This option will read a private OpenSSH format file and print an
18948185Ssheldonh             OpenSSH public key to stdout.
19048185Ssheldonh
19152609SdillonMODULI GENERATION
19252609Sdillon     ssh-keygen may be used to generate groups for the Diffie-Hellman Group
19358979Siwasaki     Exchange (DH-GEX) protocol.  Generating these groups is a two-step pro-
19458979Siwasaki     cess: first, candidate primes are generated using a fast, but memory in-
19562006Snbm     tensive process.  These candidate primes are then tested for suitability
19661981Sbrian     (a CPU-intensive process).
19748185Ssheldonh
19848185Ssheldonh     Generation of primes is performed using the -G option.  The desired
19937Srgrimes     length of the primes may be specified by the -b option.  For example:
200
201           # ssh-keygen -G moduli-2048.candidates -b 2048
202
203     By default, the search for primes begins at a random point in the desired
204     length range.  This may be overridden using the -S option, which speci-
205     fies a different start point (in hex).
206
207     Once a set of candidates have been generated, they must be tested for
208     suitability.  This may be performed using the -T option.  In this mode
209     ssh-keygen will read candidates from standard input (or a file specified
210     using the -f option).  For example:
211
212           # ssh-keygen -T moduli-2048 -f moduli-2048.candidates
213
214     By default, each candidate will be subjected to 100 primality tests.
215     This may be overridden using the -a option.  The DH generator value will
216     be chosen automatically for the prime under consideration.  If a specific
217     generator is desired, it may be requested using the -W option.  Valid
218     generator values are 2, 3, and 5.
219
220     Screened DH groups may be installed in /etc/moduli.  It is important that
221     this file contains moduli of a range of bit lengths and that both ends of
222     a connection share common moduli.
223
224FILES
225     ~/.ssh/identity
226             Contains the protocol version 1 RSA authentication identity of
227             the user.  This file should not be readable by anyone but the us-
228             er.  It is possible to specify a passphrase when generating the
229             key; that passphrase will be used to encrypt the private part of
230             this file using 3DES.  This file is not automatically accessed by
231             ssh-keygen but it is offered as the default file for the private
232             key.  ssh(1) will read this file when a login attempt is made.
233
234     ~/.ssh/identity.pub
235             Contains the protocol version 1 RSA public key for authentica-
236             tion.  The contents of this file should be added to
237             ~/.ssh/authorized_keys on all machines where the user wishes to
238             log in using RSA authentication.  There is no need to keep the
239             contents of this file secret.
240
241     ~/.ssh/id_dsa
242             Contains the protocol version 2 DSA authentication identity of
243             the user.  This file should not be readable by anyone but the us-
244             er.  It is possible to specify a passphrase when generating the
245             key; that passphrase will be used to encrypt the private part of
246             this file using 3DES.  This file is not automatically accessed by
247             ssh-keygen but it is offered as the default file for the private
248             key.  ssh(1) will read this file when a login attempt is made.
249
250     ~/.ssh/id_dsa.pub
251             Contains the protocol version 2 DSA public key for authentica-
252             tion.  The contents of this file should be added to
253             ~/.ssh/authorized_keys on all machines where the user wishes to
254             log in using public key authentication.  There is no need to keep
255             the contents of this file secret.
256
257     ~/.ssh/id_rsa
258             Contains the protocol version 2 RSA authentication identity of
259             the user.  This file should not be readable by anyone but the us-
260             er.  It is possible to specify a passphrase when generating the
261             key; that passphrase will be used to encrypt the private part of
262             this file using 3DES.  This file is not automatically accessed by
263             ssh-keygen but it is offered as the default file for the private
264             key.  ssh(1) will read this file when a login attempt is made.
265
266     ~/.ssh/id_rsa.pub
267             Contains the protocol version 2 RSA public key for authentica-
268             tion.  The contents of this file should be added to
269             ~/.ssh/authorized_keys on all machines where the user wishes to
270             log in using public key authentication.  There is no need to keep
271             the contents of this file secret.
272
273     /etc/moduli
274             Contains Diffie-Hellman groups used for DH-GEX.  The file format
275             is described in moduli(5).
276
277SEE ALSO
278     ssh(1), ssh-add(1), ssh-agent(1), moduli(5), sshd(8)
279
280     The Secure Shell (SSH) Public Key File Format, RFC 4716, 2006.
281
282AUTHORS
283     OpenSSH is a derivative of the original and free ssh 1.2.12 release by
284     Tatu Ylonen.  Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo
285     de Raadt and Dug Song removed many bugs, re-added newer features and
286     created OpenSSH.  Markus Friedl contributed the support for SSH protocol
287     versions 1.5 and 2.0.
288
289OpenBSD 4.5                      July 24, 2008                               5
290