xref: /freebsd/crypto/openssh/ssh-keygen.1 (revision ae1f160d56b2d59d406f1af34cbdcc88a9e1b914)
1ae1f160dSDag-Erling Smørgrav.\"	$OpenBSD: ssh-keygen.1,v 1.53 2002/02/16 14:53:37 stevesk Exp $
21e8db6e2SBrian Feldman.\"
3511b41d2SMark Murray.\"  -*- nroff -*-
4511b41d2SMark Murray.\"
5511b41d2SMark Murray.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
6511b41d2SMark Murray.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
7511b41d2SMark Murray.\"                    All rights reserved
8511b41d2SMark Murray.\"
9b66f2d16SKris Kennaway.\" As far as I am concerned, the code I have written for this software
10b66f2d16SKris Kennaway.\" can be used freely for any purpose.  Any derived versions of this
11b66f2d16SKris Kennaway.\" software must be clearly marked as such, and if the derived work is
12b66f2d16SKris Kennaway.\" incompatible with the protocol description in the RFC file, it must be
13b66f2d16SKris Kennaway.\" called by a name other than "ssh" or "Secure Shell".
14511b41d2SMark Murray.\"
15b66f2d16SKris Kennaway.\"
16b66f2d16SKris Kennaway.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
17b66f2d16SKris Kennaway.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
18b66f2d16SKris Kennaway.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
19b66f2d16SKris Kennaway.\"
20b66f2d16SKris Kennaway.\" Redistribution and use in source and binary forms, with or without
21b66f2d16SKris Kennaway.\" modification, are permitted provided that the following conditions
22b66f2d16SKris Kennaway.\" are met:
23b66f2d16SKris Kennaway.\" 1. Redistributions of source code must retain the above copyright
24b66f2d16SKris Kennaway.\"    notice, this list of conditions and the following disclaimer.
25b66f2d16SKris Kennaway.\" 2. Redistributions in binary form must reproduce the above copyright
26b66f2d16SKris Kennaway.\"    notice, this list of conditions and the following disclaimer in the
27b66f2d16SKris Kennaway.\"    documentation and/or other materials provided with the distribution.
28b66f2d16SKris Kennaway.\"
29b66f2d16SKris Kennaway.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
30b66f2d16SKris Kennaway.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
31b66f2d16SKris Kennaway.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32b66f2d16SKris Kennaway.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
33b66f2d16SKris Kennaway.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
34b66f2d16SKris Kennaway.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35b66f2d16SKris Kennaway.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36b66f2d16SKris Kennaway.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37b66f2d16SKris Kennaway.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
38b66f2d16SKris Kennaway.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39511b41d2SMark Murray.\"
40511b41d2SMark Murray.Dd September 25, 1999
41511b41d2SMark Murray.Dt SSH-KEYGEN 1
42511b41d2SMark Murray.Os
43511b41d2SMark Murray.Sh NAME
44511b41d2SMark Murray.Nm ssh-keygen
451e8db6e2SBrian Feldman.Nd authentication key generation, management and conversion
46511b41d2SMark Murray.Sh SYNOPSIS
47511b41d2SMark Murray.Nm ssh-keygen
481e8db6e2SBrian Feldman.Op Fl q
49511b41d2SMark Murray.Op Fl b Ar bits
50ae1f160dSDag-Erling Smørgrav.Fl t Ar type
51511b41d2SMark Murray.Op Fl N Ar new_passphrase
52511b41d2SMark Murray.Op Fl C Ar comment
53b66f2d16SKris Kennaway.Op Fl f Ar output_keyfile
54511b41d2SMark Murray.Nm ssh-keygen
55511b41d2SMark Murray.Fl p
56511b41d2SMark Murray.Op Fl P Ar old_passphrase
57511b41d2SMark Murray.Op Fl N Ar new_passphrase
58511b41d2SMark Murray.Op Fl f Ar keyfile
59511b41d2SMark Murray.Nm ssh-keygen
601e8db6e2SBrian Feldman.Fl i
61b66f2d16SKris Kennaway.Op Fl f Ar input_keyfile
62a04a10f8SKris Kennaway.Nm ssh-keygen
631e8db6e2SBrian Feldman.Fl e
64b66f2d16SKris Kennaway.Op Fl f Ar input_keyfile
65a04a10f8SKris Kennaway.Nm ssh-keygen
66a04a10f8SKris Kennaway.Fl y
67b66f2d16SKris Kennaway.Op Fl f Ar input_keyfile
68a04a10f8SKris Kennaway.Nm ssh-keygen
69511b41d2SMark Murray.Fl c
70511b41d2SMark Murray.Op Fl P Ar passphrase
71511b41d2SMark Murray.Op Fl C Ar comment
72511b41d2SMark Murray.Op Fl f Ar keyfile
73511b41d2SMark Murray.Nm ssh-keygen
74511b41d2SMark Murray.Fl l
75b66f2d16SKris Kennaway.Op Fl f Ar input_keyfile
76a04a10f8SKris Kennaway.Nm ssh-keygen
771e8db6e2SBrian Feldman.Fl B
781e8db6e2SBrian Feldman.Op Fl f Ar input_keyfile
79ae1f160dSDag-Erling Smørgrav.Nm ssh-keygen
80ae1f160dSDag-Erling Smørgrav.Fl D Ar reader
81ae1f160dSDag-Erling Smørgrav.Nm ssh-keygen
82ae1f160dSDag-Erling Smørgrav.Fl U Ar reader
83ae1f160dSDag-Erling Smørgrav.Op Fl f Ar input_keyfile
84511b41d2SMark Murray.Sh DESCRIPTION
85511b41d2SMark Murray.Nm
861e8db6e2SBrian Feldmangenerates, manages and converts authentication keys for
87511b41d2SMark Murray.Xr ssh 1 .
88a04a10f8SKris Kennaway.Nm
89ae1f160dSDag-Erling Smørgravcan create RSA keys for use by SSH protocol version 1 and RSA or DSA
90ae1f160dSDag-Erling Smørgravkeys for use by SSH protocol version 2. The type of key to be generated
91ae1f160dSDag-Erling Smørgravis specified with the
921e8db6e2SBrian Feldman.Fl t
93ae1f160dSDag-Erling Smørgravoption.
94a04a10f8SKris Kennaway.Pp
95511b41d2SMark MurrayNormally each user wishing to use SSH
96a04a10f8SKris Kennawaywith RSA or DSA authentication runs this once to create the authentication
97511b41d2SMark Murraykey in
981e8db6e2SBrian Feldman.Pa $HOME/.ssh/identity ,
991e8db6e2SBrian Feldman.Pa $HOME/.ssh/id_dsa
100a04a10f8SKris Kennawayor
1011e8db6e2SBrian Feldman.Pa $HOME/.ssh/id_rsa .
102a04a10f8SKris KennawayAdditionally, the system administrator may use this to generate host keys,
103a04a10f8SKris Kennawayas seen in
104a04a10f8SKris Kennaway.Pa /etc/rc .
105511b41d2SMark Murray.Pp
106511b41d2SMark MurrayNormally this program generates the key and asks for a file in which
107a8f6863aSKris Kennawayto store the private key.
108a8f6863aSKris KennawayThe public key is stored in a file with the same name but
109511b41d2SMark Murray.Dq .pub
110a8f6863aSKris Kennawayappended.
111a8f6863aSKris KennawayThe program also asks for a passphrase.
112a8f6863aSKris KennawayThe passphrase may be empty to indicate no passphrase
1131e8db6e2SBrian Feldman(host keys must have an empty passphrase), or it may be a string of
114a8f6863aSKris Kennawayarbitrary length.
115ae1f160dSDag-Erling SmørgravA passphrase is similar to a password, except it can be a phrase with a
116ae1f160dSDag-Erling Smørgravseries of words, punctuation, numbers, whitespace, or any string of
117ae1f160dSDag-Erling Smørgravcharacters you want.
118ae1f160dSDag-Erling SmørgravGood passphrases are 10-30 characters long, are
119511b41d2SMark Murraynot simple sentences or otherwise easily guessable (English
120ae1f160dSDag-Erling Smørgravprose has only 1-2 bits of entropy per character, and provides very bad
121ae1f160dSDag-Erling Smørgravpassphrases), and contain a mix of upper and lowercase letters,
122ae1f160dSDag-Erling Smørgravnumbers, and non-alphanumeric characters.
123a8f6863aSKris KennawayThe passphrase can be changed later by using the
124511b41d2SMark Murray.Fl p
125511b41d2SMark Murrayoption.
126511b41d2SMark Murray.Pp
127a8f6863aSKris KennawayThere is no way to recover a lost passphrase.
128a8f6863aSKris KennawayIf the passphrase is
129ae1f160dSDag-Erling Smørgravlost or forgotten, a new key must be generated and copied to the
130511b41d2SMark Murraycorresponding public key to other machines.
131511b41d2SMark Murray.Pp
1321e8db6e2SBrian FeldmanFor RSA1 keys,
1331e8db6e2SBrian Feldmanthere is also a comment field in the key file that is only for
134a8f6863aSKris Kennawayconvenience to the user to help identify the key.
135a8f6863aSKris KennawayThe comment can tell what the key is for, or whatever is useful.
136a8f6863aSKris KennawayThe comment is initialized to
137511b41d2SMark Murray.Dq user@host
138511b41d2SMark Murraywhen the key is created, but can be changed using the
139511b41d2SMark Murray.Fl c
140511b41d2SMark Murrayoption.
141511b41d2SMark Murray.Pp
142a04a10f8SKris KennawayAfter a key is generated, instructions below detail where the keys
143a04a10f8SKris Kennawayshould be placed to be activated.
144a04a10f8SKris Kennaway.Pp
145511b41d2SMark MurrayThe options are as follows:
146511b41d2SMark Murray.Bl -tag -width Ds
147511b41d2SMark Murray.It Fl b Ar bits
148a8f6863aSKris KennawaySpecifies the number of bits in the key to create.
149a8f6863aSKris KennawayMinimum is 512 bits.
150a8f6863aSKris KennawayGenerally 1024 bits is considered sufficient, and key sizes
151a8f6863aSKris Kennawayabove that no longer improve security but make things slower.
152a8f6863aSKris KennawayThe default is 1024 bits.
153511b41d2SMark Murray.It Fl c
154511b41d2SMark MurrayRequests changing the comment in the private and public key files.
155ae1f160dSDag-Erling SmørgravThis operation is only supported for RSA1 keys.
156511b41d2SMark MurrayThe program will prompt for the file containing the private keys, for
157ae1f160dSDag-Erling Smørgravthe passphrase if the key has one, and for the new comment.
1581e8db6e2SBrian Feldman.It Fl e
1591e8db6e2SBrian FeldmanThis option will read a private or public OpenSSH key file and
1601e8db6e2SBrian Feldmanprint the key in a
1611e8db6e2SBrian Feldman.Sq SECSH Public Key File Format
1621e8db6e2SBrian Feldmanto stdout.
1631e8db6e2SBrian FeldmanThis option allows exporting keys for use by several commercial
1641e8db6e2SBrian FeldmanSSH implementations.
165ae1f160dSDag-Erling Smørgrav.It Fl f Ar filename
166511b41d2SMark MurraySpecifies the filename of the key file.
1671e8db6e2SBrian Feldman.It Fl i
1681e8db6e2SBrian FeldmanThis option will read an unencrypted private (or public) key file
1691e8db6e2SBrian Feldmanin SSH2-compatible format and print an OpenSSH compatible private
1701e8db6e2SBrian Feldman(or public) key to stdout.
1711e8db6e2SBrian Feldman.Nm
1721e8db6e2SBrian Feldmanalso reads the
1731e8db6e2SBrian Feldman.Sq SECSH Public Key File Format .
1741e8db6e2SBrian FeldmanThis option allows importing keys from several commercial
1751e8db6e2SBrian FeldmanSSH implementations.
176511b41d2SMark Murray.It Fl l
177ae1f160dSDag-Erling SmørgravShow fingerprint of specified public key file.
178ae1f160dSDag-Erling SmørgravPrivate RSA1 keys are also supported.
179ae1f160dSDag-Erling SmørgravFor RSA and DSA keys
180ae1f160dSDag-Erling Smørgrav.Nm
181ae1f160dSDag-Erling Smørgravtries to find the matching public key file and prints its fingerprint.
182511b41d2SMark Murray.It Fl p
183511b41d2SMark MurrayRequests changing the passphrase of a private key file instead of
184a8f6863aSKris Kennawaycreating a new private key.
185a8f6863aSKris KennawayThe program will prompt for the file
186511b41d2SMark Murraycontaining the private key, for the old passphrase, and twice for the
187511b41d2SMark Murraynew passphrase.
188511b41d2SMark Murray.It Fl q
189511b41d2SMark MurraySilence
190511b41d2SMark Murray.Nm ssh-keygen .
191511b41d2SMark MurrayUsed by
192511b41d2SMark Murray.Pa /etc/rc
193511b41d2SMark Murraywhen creating a new key.
1941e8db6e2SBrian Feldman.It Fl y
1951e8db6e2SBrian FeldmanThis option will read a private
1961e8db6e2SBrian FeldmanOpenSSH format file and print an OpenSSH public key to stdout.
1971e8db6e2SBrian Feldman.It Fl t Ar type
1981e8db6e2SBrian FeldmanSpecifies the type of the key to create.
1991e8db6e2SBrian FeldmanThe possible values are
2001e8db6e2SBrian Feldman.Dq rsa1
2011e8db6e2SBrian Feldmanfor protocol version 1 and
2021e8db6e2SBrian Feldman.Dq rsa
2031e8db6e2SBrian Feldmanor
2041e8db6e2SBrian Feldman.Dq dsa
2051e8db6e2SBrian Feldmanfor protocol version 2.
2061e8db6e2SBrian Feldman.It Fl B
2071e8db6e2SBrian FeldmanShow the bubblebabble digest of specified private or public key file.
208511b41d2SMark Murray.It Fl C Ar comment
209511b41d2SMark MurrayProvides the new comment.
210ae1f160dSDag-Erling Smørgrav.It Fl D Ar reader
211ae1f160dSDag-Erling SmørgravDownload the RSA public key stored in the smartcard in
212ae1f160dSDag-Erling Smørgrav.Ar reader .
213511b41d2SMark Murray.It Fl N Ar new_passphrase
214511b41d2SMark MurrayProvides the new passphrase.
215511b41d2SMark Murray.It Fl P Ar passphrase
216511b41d2SMark MurrayProvides the (old) passphrase.
217ae1f160dSDag-Erling Smørgrav.It Fl U Ar reader
218ae1f160dSDag-Erling SmørgravUpload an existing RSA private key into the smartcard in
219ae1f160dSDag-Erling Smørgrav.Ar reader .
220511b41d2SMark Murray.El
221511b41d2SMark Murray.Sh FILES
222511b41d2SMark Murray.Bl -tag -width Ds
223511b41d2SMark Murray.It Pa $HOME/.ssh/identity
2241e8db6e2SBrian FeldmanContains the protocol version 1 RSA authentication identity of the user.
225a8f6863aSKris KennawayThis file should not be readable by anyone but the user.
226a8f6863aSKris KennawayIt is possible to
227511b41d2SMark Murrayspecify a passphrase when generating the key; that passphrase will be
228a8f6863aSKris Kennawayused to encrypt the private part of this file using 3DES.
229a8f6863aSKris KennawayThis file is not automatically accessed by
230511b41d2SMark Murray.Nm
231511b41d2SMark Murraybut it is offered as the default file for the private key.
232ae1f160dSDag-Erling Smørgrav.Xr ssh 1
233a04a10f8SKris Kennawaywill read this file when a login attempt is made.
234511b41d2SMark Murray.It Pa $HOME/.ssh/identity.pub
2351e8db6e2SBrian FeldmanContains the protocol version 1 RSA public key for authentication.
236a8f6863aSKris KennawayThe contents of this file should be added to
237511b41d2SMark Murray.Pa $HOME/.ssh/authorized_keys
238511b41d2SMark Murrayon all machines
239ae1f160dSDag-Erling Smørgravwhere the user wishes to log in using RSA authentication.
240a8f6863aSKris KennawayThere is no need to keep the contents of this file secret.
241a04a10f8SKris Kennaway.It Pa $HOME/.ssh/id_dsa
2421e8db6e2SBrian FeldmanContains the protocol version 2 DSA authentication identity of the user.
243a04a10f8SKris KennawayThis file should not be readable by anyone but the user.
244a04a10f8SKris KennawayIt is possible to
245a04a10f8SKris Kennawayspecify a passphrase when generating the key; that passphrase will be
246a04a10f8SKris Kennawayused to encrypt the private part of this file using 3DES.
247a04a10f8SKris KennawayThis file is not automatically accessed by
248a04a10f8SKris Kennaway.Nm
249a04a10f8SKris Kennawaybut it is offered as the default file for the private key.
250ae1f160dSDag-Erling Smørgrav.Xr ssh 1
251a04a10f8SKris Kennawaywill read this file when a login attempt is made.
252a04a10f8SKris Kennaway.It Pa $HOME/.ssh/id_dsa.pub
2531e8db6e2SBrian FeldmanContains the protocol version 2 DSA public key for authentication.
254a04a10f8SKris KennawayThe contents of this file should be added to
255ae1f160dSDag-Erling Smørgrav.Pa $HOME/.ssh/authorized_keys
256a04a10f8SKris Kennawayon all machines
257ae1f160dSDag-Erling Smørgravwhere the user wishes to log in using public key authentication.
2581e8db6e2SBrian FeldmanThere is no need to keep the contents of this file secret.
2591e8db6e2SBrian Feldman.It Pa $HOME/.ssh/id_rsa
2601e8db6e2SBrian FeldmanContains the protocol version 2 RSA authentication identity of the user.
2611e8db6e2SBrian FeldmanThis file should not be readable by anyone but the user.
2621e8db6e2SBrian FeldmanIt is possible to
2631e8db6e2SBrian Feldmanspecify a passphrase when generating the key; that passphrase will be
2641e8db6e2SBrian Feldmanused to encrypt the private part of this file using 3DES.
2651e8db6e2SBrian FeldmanThis file is not automatically accessed by
2661e8db6e2SBrian Feldman.Nm
2671e8db6e2SBrian Feldmanbut it is offered as the default file for the private key.
268ae1f160dSDag-Erling Smørgrav.Xr ssh 1
2691e8db6e2SBrian Feldmanwill read this file when a login attempt is made.
2701e8db6e2SBrian Feldman.It Pa $HOME/.ssh/id_rsa.pub
2711e8db6e2SBrian FeldmanContains the protocol version 2 RSA public key for authentication.
2721e8db6e2SBrian FeldmanThe contents of this file should be added to
273ae1f160dSDag-Erling Smørgrav.Pa $HOME/.ssh/authorized_keys
2741e8db6e2SBrian Feldmanon all machines
275ae1f160dSDag-Erling Smørgravwhere the user wishes to log in using public key authentication.
276a04a10f8SKris KennawayThere is no need to keep the contents of this file secret.
277b66f2d16SKris Kennaway.El
2781e8db6e2SBrian Feldman.Sh AUTHORS
2791e8db6e2SBrian FeldmanOpenSSH is a derivative of the original and free
2801e8db6e2SBrian Feldmanssh 1.2.12 release by Tatu Ylonen.
2811e8db6e2SBrian FeldmanAaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
2821e8db6e2SBrian FeldmanTheo de Raadt and Dug Song
2831e8db6e2SBrian Feldmanremoved many bugs, re-added newer features and
2841e8db6e2SBrian Feldmancreated OpenSSH.
2851e8db6e2SBrian FeldmanMarkus Friedl contributed the support for SSH
2861e8db6e2SBrian Feldmanprotocol versions 1.5 and 2.0.
287511b41d2SMark Murray.Sh SEE ALSO
288511b41d2SMark Murray.Xr ssh 1 ,
289511b41d2SMark Murray.Xr ssh-add 1 ,
290511b41d2SMark Murray.Xr ssh-agent 1 ,
2911e8db6e2SBrian Feldman.Xr sshd 8
2921e8db6e2SBrian Feldman.Rs
2931e8db6e2SBrian Feldman.%A J. Galbraith
2941e8db6e2SBrian Feldman.%A R. Thayer
2951e8db6e2SBrian Feldman.%T "SECSH Public Key File Format"
2961e8db6e2SBrian Feldman.%N draft-ietf-secsh-publickeyfile-01.txt
2971e8db6e2SBrian Feldman.%D March 2001
2981e8db6e2SBrian Feldman.%O work in progress material
2991e8db6e2SBrian Feldman.Re
300