1ntp-keygen(8) System Manager's Manual ntp-keygen(8)
2
3
4
6 ntp-keygen - generate public and private keys
7
8
10 ntp-keygen [ -deGgHIMPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1
11 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ -i name ] [ -p
12 password ] [ -q password ] [ -S [ RSA | DSA ] ] [ -s name ] [ -v nkeys
13 ] [ -V params ]
14
15
17 This program generates cryptographic data files used by the NTPv4
18 authentication and identification schemes. It generates MD5 key files
19 used in symmetric key cryptography. In addition, if the OpenSSL soft‐
20 ware library has been installed, it generates keys, certificate and
21 identity files used in public key cryptography. These files are used
22 for cookie encryption, digital signature and challenge/response identi‐
23 fication algorithms compatible with the Internet standard security in‐
24 frastructure.
25
26 By default, files are not encrypted by ntp-keygen. The -p password
27 option specifies the write password and -q password option the read
28 password for previously encrypted files. The ntp-keygen program prompts
29 for the password if it reads an encrypted file and the password is
30 missing or incorrect. If an encrypted file is read successfully and no
31 write password is specified, the read password is used as the write
32 password by default.
33
34 The ntpd configuration command crypto pw password specifies the read
35 password for previously encrypted files. The daemon expires on the spot
36 if the password is missing or incorrect. For convenience, if a file has
37 been previously encrypted, the default read password is the name of the
38 host running the program. If the previous write password is specified
39 as the host name, these files can be read by that host with no explicit
40 password.
41
42 All files are in PEM-encoded printable ASCII format, so they can be
43 embedded as MIME attachments in mail to other sites and certificate
44 authorities. File names begin with the prefix ntpkey_ and end with the
45 postfix _hostname.filestamp, where hostname is usually the string
46 returned by the Unix gethostname() routine, and filestamp is the NTP
47 seconds when the file was generated, in decimal digits. This both guar‐
48 antees uniqueness and simplifies maintenance procedures, since all
49 files can be quickly removed by a rm ntpkey* command or all files gen‐
50 erated at a specific time can be removed by a rm *filestamp command. To
51 further reduce the risk of misconfiguration, the first two lines of a
52 file contain the file name and generation date and time as comments.
53
54 All files are installed by default in the keys directory
55 /usr/local/etc, which is normally in a shared filesystem in NFS-mounted
56 networks. The actual location of the keys directory and each file can
57 be overridden by configuration commands, but this is not recommended.
58 Normally, the files for each host are generated by that host and used
59 only by that host, although exceptions exist as noted later on this
60 page.
61
62 Normally, files containing private values, including the host key, sign
63 key and identification parameters, are permitted root read/write-only;
64 while others containing public values are permitted world readable.
65 Alternatively, files containing private values can be encrypted and
66 these files permitted world readable, which simplifies maintenance in
67 shared file systems. Since uniqueness is insured by the hostname and
68 file name extensions, the files for a NFS server and dependent clients
69 can all be installed in the same shared directory.
70
71 The recommended practice is to keep the file name extensions when
72 installing a file and to install a soft link from the generic names
73 specified elsewhere on this page to the generated files. This allows
74 new file generations to be activated simply by changing the link. If a
75 link is present, ntpd follows it to the file name to extract the
76 filestamp. If a link is not present, ntpd extracts the filestamp from
77 the file itself. This allows clients to verify that the file and gener‐
78 ation times are always current. The ntp-keygen program uses the same
79 extension for all files generated at one time, so each generation is
80 distinct and can be readily recognized in monitoring data.
81
82
84 The safest way to run the ntp-keygen program is logged in directly as
85 root. The recommended procedure is change to the keys directory, usu‐
86 ally /ust/local/etc, then run the program. When run for the first time,
87 or if all ntpkey files have been removed, the program generates a RSA
88 host key file and matching RSA-MD5 certificate file, which is all that
89 is necessary in many cases. The program also generates soft links from
90 the generic names to the respective files. If run again, the program
91 uses the same host key file, but generates a new certificate file and
92 link.
93
94 The host key is used to encrypt the cookie when required and so must be
95 RSA type. By default, the host key is also the sign key used to encrypt
96 signatures. When necessary, a different sign key can be specified and
97 this can be either RSA or DSA type. By default, the message digest type
98 is MD5, but any combination of sign key type and message digest type
99 supported by the OpenSSL library can be specified, including those
100 using the MD2, MD5, SHA, SHA1, MDC2 and RIPE160 message digest algo‐
101 rithms. However, the scheme specified in the certificate must be com‐
102 patible with the sign key. Certificates using any digest algorithm are
103 compatible with RSA sign keys; however, only SHA and SHA1 certificates
104 are compatible with DSA sign keys.
105
106 Private/public key files and certificates are compatible with other
107 OpenSSL applications and very likely other libraries as well. Certifi‐
108 cates or certificate requests derived from them should be compatible
109 with extant industry practice, although some users might find the
110 interpretation of X509v3 extension fields somewhat liberal. However,
111 the identification parameter files, although encoded as the other
112 files, are probably not compatible with anything other than Autokey.
113
114 Running the program as other than root and using the Unix su command to
115 assume root may not work properly, since by default the OpenSSL library
116 looks for the random seed file .rnd in the user home directory. How‐
117 ever, there should be only one .rnd, most conveniently in the root
118 directory, so it is convenient to define the $RANDFILE environment
119 variable used by the OpenSSL library as the path to /.rnd.
120
121 Installing the keys as root might not work in NFS-mounted shared file
122 systems, as NFS clients may not be able to write to the shared keys
123 directory, even as root. In this case, NFS clients can specify the
124 files in another directory such as /etc using the keysdir command.
125 There is no need for one client to read the keys and certificates of
126 other clients or servers, as these data are obtained automatically by
127 the Autokey protocol.
128
129 Ordinarily, cryptographic files are generated by the host that uses
130 them, but it is possible for a trusted agent (TA) to generate these
131 files for other hosts; however, in such cases files should always be
132 encrypted. The subject name and trusted name default to the hostname of
133 the host generating the files, but can be changed by command line
134 options. It is convenient to designate the owner name and trusted name
135 as the subject and issuer fields, respectively, of the certificate. The
136 owner name is also used for the host and sign key files, while the
137 trusted name is used for the identity files.
138
139
141 Each cryptographic configuration involves selection of a signature
142 scheme and identification scheme, called a cryptotype, as explained in
143 the Authentication Options page. The default cryptotype uses RSA
144 encryption, MD5 message digest and TC identification. First, configure
145 a NTP subnet including one or more low-stratum trusted hosts from which
146 all other hosts derive synchronization directly or indirectly. Trusted
147 hosts have trusted certificates; all other hosts have nontrusted cer‐
148 tificates. These hosts will automatically and dynamically build author‐
149 itative certificate trails to one or more trusted hosts. A trusted
150 group is the set of all hosts that have, directly or indirectly, a cer‐
151 tificate trail ending at a trusted host. The trail is defined by static
152 configuration file entries or dynamic means described on the Automatic
153 NTP Configuration Options page.
154
155 On each trusted host as root, change to the keys directory. To insure a
156 fresh fileset, remove all ntpkey files. Then run ntp-keygen -T to gen‐
157 erate keys and a trusted certificate. On all other hosts do the same,
158 but leave off the -T flag to generate keys and nontrusted certificates.
159 When complete, start the NTP daemons beginning at the lowest stratum
160 and working up the tree. It may take some time for Autokey to instanti‐
161 ate the certificate trails throughout the subnet, but setting up the
162 environment is completely automatic.
163
164 If it is necessary to use a different sign key or different digest/sig‐
165 nature scheme than the default, run ntp-keygen with the -S type option,
166 where type is either RSA or DSA. The most often need to do this is when
167 a DSA-signed certificate is used. If it is necessary to use a different
168 certificate scheme than the default, run ntp-keygen with the -c scheme
169 option and selected scheme as needed. If ntp-keygen is run again with‐
170 out these options, it generates a new certificate using the same scheme
171 and sign key.
172
173 After setting up the environment it is advisable to update certificates
174 from time to time, if only to extend the validity interval. Simply run
175 ntp-keygen with the same flags as before to generate new certificates
176 using existing keys. However, if the host or sign key is changed, ntpd
177 should be restarted. When ntpd is restarted, it loads any new files and
178 restarts the protocol. Other dependent hosts will continue as usual
179 until signatures are refreshed, at which time the protocol is
180 restarted.
181
182
184 As mentioned on the Autonomous Authentication page, the default TC
185 identity scheme is vulnerable to a middleman attack. However, there are
186 more secure identity schemes available, including PC, IFF, GQ and MV
187 described on the Identification Schemes page. These schemes are based
188 on a TA, one or more trusted hosts and some number of nontrusted hosts.
189 Trusted hosts prove identity using values provided by the TA, while the
190 remaining hosts prove identity using values provided by a trusted host
191 and certificate trails that end on that host. The name of a trusted
192 host is also the name of its sugroup and also the subject and issuer
193 name on its trusted certificate. The TA is not necessarily a trusted
194 host in this sense, but often is.
195
196 In some schemes there are separate keys for servers and clients. A
197 server can also be a client of another server, but a client can never
198 be a server for another client. In general, trusted hosts and non‐
199 trusted hosts that operate as both server and client have parameter
200 files that contain both server and client keys. Hosts that operate only
201 as clients have key files that contain only client keys.
202
203 The PC scheme supports only one trusted host in the group. On trusted
204 host alice run ntp-keygen -P -p password to generate the host key file
205 ntpkey_RSAkey_alice.filestamp and trusted private certificate file ntp‐
206 key_RSA-MD5_cert_alice.filestamp. Copy both files to all group hosts;
207 they replace the files which would be generated in other schemes. On
208 each host bob install a soft link from the generic name ntpkey_host_bob
209 to the host key file and soft link ntpkey_cert_bob to the private cer‐
210 tificate file. Note the generic links are on bob, but point to files
211 generated by trusted host alice. In this scheme it is not possible to
212 refresh either the keys or certificates without copying them to all
213 other hosts in the group.
214
215 For the IFF scheme proceed as in the TC scheme to generate keys and
216 certificates for all group hosts, then for every trusted host in the
217 group, generate the IFF parameter file. On trusted host alice run ntp-
218 keygen -T -I -p password to produce her parameter file ntpkey_IFF‐
219 par_alice.filestamp, which includes both server and client keys. Copy
220 this file to all group hosts that operate as both servers and clients
221 and install a soft link from the generic ntpkey_iff_alice to this file.
222 If there are no hosts restricted to operate only as clients, there is
223 nothing further to do. As the IFF scheme is independent of keys and
224 certificates, these files can be refreshed as needed.
225
226 If a rogue client has the parameter file, it could masquerade as a
227 legitimate server and present a middleman threat. To eliminate this
228 threat, the client keys can be extracted from the parameter file and
229 distributed to all restricted clients. After generating the parameter
230 file, on alice run ntp-keygen -e and pipe the output to a file or mail
231 program. Copy or mail this file to all restricted clients. On these
232 clients install a soft link from the generic ntpkey_iff_alice to this
233 file. To further protect the integrity of the keys, each file can be
234 encrypted with a secret password.
235
236 For the GQ scheme proceed as in the TC scheme to generate keys and cer‐
237 tificates for all group hosts, then for every trusted host in the
238 group, generate the IFF parameter file. On trusted host alice run ntp-
239 keygen -T -G -p password to produce her parameter file ntp‐
240 key_GQpar_alice.filestamp, which includes both server and client keys.
241 Copy this file to all group hosts and install a soft link from the
242 generic ntpkey_gq_alice to this file. In addition, on each host bob
243 install a soft link from generic ntpkey_gq_bob to this file. As the GQ
244 scheme updates the GQ parameters file and certificate at the same time,
245 keys and certificates can be regenerated as needed.
246
247 For the MV scheme, proceed as in the TC scheme to generate keys and
248 certificates for all group hosts. For illustration assume trish is the
249 TA, alice one of several trusted hosts and bob one of her clients. On
250 TA trish run ntp-keygen -V n -p password, where n is the number of
251 revokable keys (typically 5) to produce the parameter file ntp‐
252 keys_MVpar_trish.filestamp and client key files ntp‐
253 keys_MVkeyd_trish.filestamp where d is the key number (0 < d < n). Copy
254 the parameter file to alice and install a soft link from the generic
255 ntpkey_mv_alice to this file. Copy one of the client key files to alice
256 for later distribution to her clients. It doesn't matter which client
257 key file goes to alice, since they all work the same way. Alice copies
258 the client key file to all of her cliens. On client bob install a soft
259 link from generic ntpkey_mvkey_bob to the client key file. As the MV
260 scheme is independent of keys and certificates, these files can be
261 refreshed as needed.
262
263
265 -c [ RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160
266 | DSA-SHA | DSA-SHA1 ]
267 Select certificate message digest/signature encryption scheme.
268 Note that RSA schemes must be used with a RSA sign key and DSA
269 schemes must be used with a DSA sign key. The default without
270 this option is RSA-MD5.
271
272 -d Enable debugging. This option displays the cryptographic data
273 produced in eye-friendly billboards.
274
275 -e Write the IFF client keys to the standard output. This is
276 intended for automatic key distribution by mail.
277
278 -G Generate parameters and keys for the GQ identification scheme,
279 obsoleting any that may exist.
280
281 -g Generate keys for the GQ identification scheme using the exist‐
282 ing GQ parameters. If the GQ parameters do not yet exist, cre‐
283 ate them first.
284
285 -H Generate new host keys, obsoleting any that may exist.
286
287 -I Generate parameters for the IFF identification scheme, obsolet‐
288 ing any that may exist.
289
290 -i name Set the suject name to name. This is used as the subject field
291 in certificates and in the file name for host and sign keys.
292
293 -M Generate MD5 keys, obsoleting any that may exist.
294
295 -m modulus
296 Set prime modulus size in bits (256 - 2048). Default size is
297 512.
298
299 -P Generate a private certificate. By default, the program gener‐
300 ates public certificates.
301
302 -p password
303 Encrypt generated files containing private data with password
304 and the DES-CBC algorithm.
305
306 -q password
307 Set the password for reading files to password.
308
309 -S [ RSA | DSA ]
310 Generate a new sign key of the designated type, obsoleting any
311 that may exist. By default, the program uses the host key as
312 the sign key.
313
314 -s name Set the issuer name to name. This is used for the issuer field
315 in certificates and in the file name for identity files.
316
317 -T Generate a trusted certificate. By default, the program gener‐
318 ates a non-trusted certificate.
319
320 -V nkeys
321 Generate parameters and keys for the Mu-Varadharajan (MV) iden‐
322 tification scheme.
323
324
326 All cryptographically sound key generation schemes must have means to
327 randomize the entropy seed used to initialize the internal pseudo-ran‐
328 dom number generator used by the library routines. The OpenSSL library
329 uses a designated random seed file for this purpose. The file must be
330 available when starting the NTP daemon and ntp-keygen program. If a
331 site supports OpenSSL or its companion OpenSSH, it is very likely that
332 means to do this are already available.
333
334 It is important to understand that entropy must be evolved for each
335 generation, for otherwise the random number sequence would be pre‐
336 dictable. Various means dependent on external events, such as keystroke
337 intervals, can be used to do this and some systems have built-in
338 entropy sources. Suitable means are described in the OpenSSL software
339 documentation, but are outside the scope of this page.
340
341 The entropy seed used by the OpenSSL library is contained in a file,
342 usually called .rnd, which must be available when starting the NTP dae‐
343 mon or the ntp-keygen program. The NTP daemon will first look for the
344 file using the path specified by the randfile subcommand of the crypto
345 configuration command. If not specified in this way, or when starting
346 the ntp-keygen program, the OpenSSL library will look for the file
347 using the path specified by the RANDFILE environment variable in the
348 user home directory, whether root or some other user. If the RANDFILE
349 environment variable is not present, the library will look for the .rnd
350 file in the user home directory. If the file is not available or cannot
351 be written, the daemon exits with a message to the system log and the
352 program exits with a suitable error message.
353
354 On systems that provide /dev/urandom, the randomness device is used
355 instead and the file specified by the randfile subcommand or the RAND‐
356 FILE environment variable is ignored.
357
358
360 All other file formats begin with two lines. The first contains the
361 file name, including the generated host name and filestamp. The second
362 contains the datestamp in conventional Unix date format. Lines begin‐
363 ning with # are considered comments and ignored by the ntp-keygen pro‐
364 gram and ntpd daemon. Cryptographic values are encoded first using
365 ASN.1 rules, then encrypted if necessary, and finally written PEM-
366 encoded printable ASCII format preceded and followed by MIME content
367 identifier lines.
368
369 The format of the symmetric keys file is somewhat different than the
370 other files in the interest of backward compatibility. Since DES-CBC is
371 deprecated in NTPv4, the only key format of interest is MD5 alphanu‐
372 meric strings. Following hte heard the keys are entered one per line in
373 the format
374
375 keyno type key
376
377 where keyno is a positive integer in the range 1-65,535, type is the
378 string MD5 defining the key format and key is the key itself, which is
379 a printable ASCII string 16 characters or less in length. Each charac‐
380 ter is chosen from the 93 printable characters in the range 0x21
381 through 0x7f excluding space and the '#' character.
382
383 Note that the keys used by the ntpq and ntpdc programs are checked
384 against passwords requested by the programs and entered by hand, so it
385 is generally appropriate to specify these keys in human readable ASCII
386 format.
387
388 The ntp-keygen program generates a MD5 symmetric keys file ntp‐
389 key_MD5key_hostname.filestamp. Since the file contains private shared
390 keys, it should be visible only to root and distributed by secure means
391 to other subnet hosts. The NTP daemon loads the file ntp.keys, so ntp-
392 keygen installs a soft link from this name to the generated file. Sub‐
393 sequently, similar soft links must be installed by manual or automated
394 means on the other subnet hosts. While this file is not used with the
395 Autokey Version 2 protocol, it is needed to authenticate some remote
396 configuration commands used by the ntpq and ntpdc utilities.
397
398
400 It can take quite a while to generate some cryptographic values, from
401 one to several minutes with modern architectures such as UltraSPARC and
402 up to tens of minutes to an hour with older architectures such as SPARC
403 IPC.
404
405
407 ntpd(8), ntp_auth(5)
408
409 Primary source of documentation: /usr/share/doc/ntp-*
410
411 This file was automatically generated from HTML source.
412
413
414
415
416 ntp-keygen(8)