ntp-keygen.8 revision 316069
1.Dd March 21 2017 2.Dt NTP_KEYGEN 8 User Commands 3.Os 4.\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc) 5.\" 6.\" $FreeBSD: stable/10/usr.sbin/ntp/doc/ntp-keygen.8 316069 2017-03-28 04:48:55Z delphij $ 7.\" 8.\" It has been AutoGen-ed March 21, 2017 at 10:45:59 AM by AutoGen 5.18.5 9.\" From the definitions ntp-keygen-opts.def 10.\" and the template file agmdoc-cmd.tpl 11.Sh NAME 12.Nm ntp-keygen 13.Nd Create a NTP host key 14.Sh SYNOPSIS 15.Nm 16.\" Mixture of short (flag) options and long options 17.Op Fl flags 18.Op Fl flag Op Ar value 19.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc 20.Pp 21All arguments must be options. 22.Pp 23.Sh DESCRIPTION 24This program generates cryptographic data files used by the NTPv4 25authentication and identification schemes. 26It generates MD5 key files used in symmetric key cryptography. 27In addition, if the OpenSSL software library has been installed, 28it generates keys, certificate and identity files used in public key 29cryptography. 30These files are used for cookie encryption, 31digital signature and challenge/response identification algorithms 32compatible with the Internet standard security infrastructure. 33.Pp 34All files are in PEM\-encoded printable ASCII format, 35so they can be embedded as MIME attachments in mail to other sites 36and certificate authorities. 37By default, files are not encrypted. 38.Pp 39When used to generate message digest keys, the program produces a file 40containing ten pseudo\-random printable ASCII strings suitable for the 41MD5 message digest algorithm included in the distribution. 42If the OpenSSL library is installed, it produces an additional ten 43hex\-encoded random bit strings suitable for the SHA1 and other message 44digest algorithms. 45The message digest keys file must be distributed and stored 46using secure means beyond the scope of NTP itself. 47Besides the keys used for ordinary NTP associations, additional keys 48can be defined as passwords for the 49.Xr ntpq 8 50and 51.Xr ntpdc 8 52utility programs. 53.Pp 54The remaining generated files are compatible with other OpenSSL 55applications and other Public Key Infrastructure (PKI) resources. 56Certificates generated by this program are compatible with extant 57industry practice, although some users might find the interpretation of 58X509v3 extension fields somewhat liberal. 59However, the identity keys are probably not compatible with anything 60other than Autokey. 61.Pp 62Some files used by this program are encrypted using a private password. 63The 64.Fl p 65option specifies the password for local encrypted files and the 66.Fl q 67option the password for encrypted files sent to remote sites. 68If no password is specified, the host name returned by the Unix 69.Fn gethostname 70function, normally the DNS name of the host is used. 71.Pp 72The 73.Ar pw 74option of the 75.Ar crypto 76configuration command specifies the read 77password for previously encrypted local files. 78This must match the local password used by this program. 79If not specified, the host name is used. 80Thus, if files are generated by this program without password, 81they can be read back by 82.Ar ntpd 83without password but only on the same host. 84.Pp 85Normally, encrypted files for each host are generated by that host and 86used only by that host, although exceptions exist as noted later on 87this page. 88The symmetric keys file, normally called 89.Ar ntp.keys , 90is usually installed in 91.Pa /etc . 92Other files and links are usually installed in 93.Pa /usr/local/etc , 94which is normally in a shared filesystem in 95NFS\-mounted networks and cannot be changed by shared clients. 96The location of the keys directory can be changed by the 97.Ar keysdir 98configuration command in such cases. 99Normally, this is in 100.Pa /etc . 101.Pp 102This program directs commentary and error messages to the standard 103error stream 104.Ar stderr 105and remote files to the standard output stream 106.Ar stdout 107where they can be piped to other applications or redirected to files. 108The names used for generated files and links all begin with the 109string 110.Ar ntpkey 111and include the file type, generating host and filestamp, 112as described in the 113.Dq Cryptographic Data Files 114section below. 115.Ss Running the Program 116To test and gain experience with Autokey concepts, log in as root and 117change to the keys directory, usually 118.Pa /usr/local/etc 119When run for the first time, or if all files with names beginning with 120.Ar ntpkey 121have been removed, use the 122.Nm 123command without arguments to generate a 124default RSA host key and matching RSA\-MD5 certificate with expiration 125date one year hence. 126If run again without options, the program uses the 127existing keys and parameters and generates only a new certificate with 128new expiration date one year hence. 129.Pp 130Run the command on as many hosts as necessary. 131Designate one of them as the trusted host (TH) using 132.Nm 133with the 134.Fl T 135option and configure it to synchronize from reliable Internet servers. 136Then configure the other hosts to synchronize to the TH directly or 137indirectly. 138A certificate trail is created when Autokey asks the immediately 139ascendant host towards the TH to sign its certificate, which is then 140provided to the immediately descendant host on request. 141All group hosts should have acyclic certificate trails ending on the TH. 142.Pp 143The host key is used to encrypt the cookie when required and so must be 144RSA type. 145By default, the host key is also the sign key used to encrypt 146signatures. 147A different sign key can be assigned using the 148.Fl S 149option and this can be either RSA or DSA type. 150By default, the signature 151message digest type is MD5, but any combination of sign key type and 152message digest type supported by the OpenSSL library can be specified 153using the 154.Fl c 155option. 156The rules say cryptographic media should be generated with proventic 157filestamps, which means the host should already be synchronized before 158this program is run. 159This of course creates a chicken\-and\-egg problem 160when the host is started for the first time. 161Accordingly, the host time 162should be set by some other means, such as eyeball\-and\-wristwatch, at 163least so that the certificate lifetime is within the current year. 164After that and when the host is synchronized to a proventic source, the 165certificate should be re\-generated. 166.Pp 167Additional information on trusted groups and identity schemes is on the 168.Dq Autokey Public\-Key Authentication 169page. 170.Pp 171The 172.Xr ntpd 8 173configuration command 174.Ic crypto pw Ar password 175specifies the read password for previously encrypted files. 176The daemon expires on the spot if the password is missing 177or incorrect. 178For convenience, if a file has been previously encrypted, 179the default read password is the name of the host running 180the program. 181If the previous write password is specified as the host name, 182these files can be read by that host with no explicit password. 183.Pp 184File names begin with the prefix 185.Cm ntpkey_ 186and end with the postfix 187.Ar _hostname.filestamp , 188where 189.Ar hostname 190is the owner name, usually the string returned 191by the Unix gethostname() routine, and 192.Ar filestamp 193is the NTP seconds when the file was generated, in decimal digits. 194This both guarantees uniqueness and simplifies maintenance 195procedures, since all files can be quickly removed 196by a 197.Ic rm ntpkey\&* 198command or all files generated 199at a specific time can be removed by a 200.Ic rm 201.Ar \&*filestamp 202command. 203To further reduce the risk of misconfiguration, 204the first two lines of a file contain the file name 205and generation date and time as comments. 206.Pp 207All files are installed by default in the keys directory 208.Pa /usr/local/etc , 209which is normally in a shared filesystem 210in NFS\-mounted networks. 211The actual location of the keys directory 212and each file can be overridden by configuration commands, 213but this is not recommended. 214Normally, the files for each host are generated by that host 215and used only by that host, although exceptions exist 216as noted later on this page. 217.Pp 218Normally, files containing private values, 219including the host key, sign key and identification parameters, 220are permitted root read/write\-only; 221while others containing public values are permitted world readable. 222Alternatively, files containing private values can be encrypted 223and these files permitted world readable, 224which simplifies maintenance in shared file systems. 225Since uniqueness is insured by the hostname and 226file name extensions, the files for a NFS server and 227dependent clients can all be installed in the same shared directory. 228.Pp 229The recommended practice is to keep the file name extensions 230when installing a file and to install a soft link 231from the generic names specified elsewhere on this page 232to the generated files. 233This allows new file generations to be activated simply 234by changing the link. 235If a link is present, ntpd follows it to the file name 236to extract the filestamp. 237If a link is not present, 238.Xr ntpd 8 239extracts the filestamp from the file itself. 240This allows clients to verify that the file and generation times 241are always current. 242The 243.Nm 244program uses the same timestamp extension for all files generated 245at one time, so each generation is distinct and can be readily 246recognized in monitoring data. 247.Ss Running the program 248The safest way to run the 249.Nm 250program is logged in directly as root. 251The recommended procedure is change to the keys directory, 252usually 253.Pa /usr/local/etc , 254then run the program. 255When run for the first time, 256or if all 257.Cm ntpkey 258files have been removed, 259the program generates a RSA host key file and matching RSA\-MD5 certificate file, 260which is all that is necessary in many cases. 261The program also generates soft links from the generic names 262to the respective files. 263If run again, the program uses the same host key file, 264but generates a new certificate file and link. 265.Pp 266The host key is used to encrypt the cookie when required and so must be RSA type. 267By default, the host key is also the sign key used to encrypt signatures. 268When necessary, a different sign key can be specified and this can be 269either RSA or DSA type. 270By default, the message digest type is MD5, but any combination 271of sign key type and message digest type supported by the OpenSSL library 272can be specified, including those using the MD2, MD5, SHA, SHA1, MDC2 273and RIPE160 message digest algorithms. 274However, the scheme specified in the certificate must be compatible 275with the sign key. 276Certificates using any digest algorithm are compatible with RSA sign keys; 277however, only SHA and SHA1 certificates are compatible with DSA sign keys. 278.Pp 279Private/public key files and certificates are compatible with 280other OpenSSL applications and very likely other libraries as well. 281Certificates or certificate requests derived from them should be compatible 282with extant industry practice, although some users might find 283the interpretation of X509v3 extension fields somewhat liberal. 284However, the identification parameter files, although encoded 285as the other files, are probably not compatible with anything other than Autokey. 286.Pp 287Running the program as other than root and using the Unix 288.Ic su 289command 290to assume root may not work properly, since by default the OpenSSL library 291looks for the random seed file 292.Cm .rnd 293in the user home directory. 294However, there should be only one 295.Cm .rnd , 296most conveniently 297in the root directory, so it is convenient to define the 298.Cm $RANDFILE 299environment variable used by the OpenSSL library as the path to 300.Cm /.rnd . 301.Pp 302Installing the keys as root might not work in NFS\-mounted 303shared file systems, as NFS clients may not be able to write 304to the shared keys directory, even as root. 305In this case, NFS clients can specify the files in another 306directory such as 307.Pa /etc 308using the 309.Ic keysdir 310command. 311There is no need for one client to read the keys and certificates 312of other clients or servers, as these data are obtained automatically 313by the Autokey protocol. 314.Pp 315Ordinarily, cryptographic files are generated by the host that uses them, 316but it is possible for a trusted agent (TA) to generate these files 317for other hosts; however, in such cases files should always be encrypted. 318The subject name and trusted name default to the hostname 319of the host generating the files, but can be changed by command line options. 320It is convenient to designate the owner name and trusted name 321as the subject and issuer fields, respectively, of the certificate. 322The owner name is also used for the host and sign key files, 323while the trusted name is used for the identity files. 324.Pp 325All files are installed by default in the keys directory 326.Pa /usr/local/etc , 327which is normally in a shared filesystem 328in NFS\-mounted networks. 329The actual location of the keys directory 330and each file can be overridden by configuration commands, 331but this is not recommended. 332Normally, the files for each host are generated by that host 333and used only by that host, although exceptions exist 334as noted later on this page. 335.Pp 336Normally, files containing private values, 337including the host key, sign key and identification parameters, 338are permitted root read/write\-only; 339while others containing public values are permitted world readable. 340Alternatively, files containing private values can be encrypted 341and these files permitted world readable, 342which simplifies maintenance in shared file systems. 343Since uniqueness is insured by the hostname and 344file name extensions, the files for a NFS server and 345dependent clients can all be installed in the same shared directory. 346.Pp 347The recommended practice is to keep the file name extensions 348when installing a file and to install a soft link 349from the generic names specified elsewhere on this page 350to the generated files. 351This allows new file generations to be activated simply 352by changing the link. 353If a link is present, ntpd follows it to the file name 354to extract the filestamp. 355If a link is not present, 356.Xr ntpd 8 357extracts the filestamp from the file itself. 358This allows clients to verify that the file and generation times 359are always current. 360The 361.Nm 362program uses the same timestamp extension for all files generated 363at one time, so each generation is distinct and can be readily 364recognized in monitoring data. 365.Ss Running the program 366The safest way to run the 367.Nm 368program is logged in directly as root. 369The recommended procedure is change to the keys directory, 370usually 371.Pa /usr/local/etc , 372then run the program. 373When run for the first time, 374or if all 375.Cm ntpkey 376files have been removed, 377the program generates a RSA host key file and matching RSA\-MD5 certificate file, 378which is all that is necessary in many cases. 379The program also generates soft links from the generic names 380to the respective files. 381If run again, the program uses the same host key file, 382but generates a new certificate file and link. 383.Pp 384The host key is used to encrypt the cookie when required and so must be RSA type. 385By default, the host key is also the sign key used to encrypt signatures. 386When necessary, a different sign key can be specified and this can be 387either RSA or DSA type. 388By default, the message digest type is MD5, but any combination 389of sign key type and message digest type supported by the OpenSSL library 390can be specified, including those using the MD2, MD5, SHA, SHA1, MDC2 391and RIPE160 message digest algorithms. 392However, the scheme specified in the certificate must be compatible 393with the sign key. 394Certificates using any digest algorithm are compatible with RSA sign keys; 395however, only SHA and SHA1 certificates are compatible with DSA sign keys. 396.Pp 397Private/public key files and certificates are compatible with 398other OpenSSL applications and very likely other libraries as well. 399Certificates or certificate requests derived from them should be compatible 400with extant industry practice, although some users might find 401the interpretation of X509v3 extension fields somewhat liberal. 402However, the identification parameter files, although encoded 403as the other files, are probably not compatible with anything other than Autokey. 404.Pp 405Running the program as other than root and using the Unix 406.Ic su 407command 408to assume root may not work properly, since by default the OpenSSL library 409looks for the random seed file 410.Cm .rnd 411in the user home directory. 412However, there should be only one 413.Cm .rnd , 414most conveniently 415in the root directory, so it is convenient to define the 416.Cm $RANDFILE 417environment variable used by the OpenSSL library as the path to 418.Cm /.rnd . 419.Pp 420Installing the keys as root might not work in NFS\-mounted 421shared file systems, as NFS clients may not be able to write 422to the shared keys directory, even as root. 423In this case, NFS clients can specify the files in another 424directory such as 425.Pa /etc 426using the 427.Ic keysdir 428command. 429There is no need for one client to read the keys and certificates 430of other clients or servers, as these data are obtained automatically 431by the Autokey protocol. 432.Pp 433Ordinarily, cryptographic files are generated by the host that uses them, 434but it is possible for a trusted agent (TA) to generate these files 435for other hosts; however, in such cases files should always be encrypted. 436The subject name and trusted name default to the hostname 437of the host generating the files, but can be changed by command line options. 438It is convenient to designate the owner name and trusted name 439as the subject and issuer fields, respectively, of the certificate. 440The owner name is also used for the host and sign key files, 441while the trusted name is used for the identity files. 442seconds. 443seconds. 444s Trusted Hosts and Groups 445Each cryptographic configuration involves selection of a signature scheme 446and identification scheme, called a cryptotype, 447as explained in the 448.Sx Authentication Options 449section of 450.Xr ntp.conf 5 . 451The default cryptotype uses RSA encryption, MD5 message digest 452and TC identification. 453First, configure a NTP subnet including one or more low\-stratum 454trusted hosts from which all other hosts derive synchronization 455directly or indirectly. 456Trusted hosts have trusted certificates; 457all other hosts have nontrusted certificates. 458These hosts will automatically and dynamically build authoritative 459certificate trails to one or more trusted hosts. 460A trusted group is the set of all hosts that have, directly or indirectly, 461a certificate trail ending at a trusted host. 462The trail is defined by static configuration file entries 463or dynamic means described on the 464.Sx Automatic NTP Configuration Options 465section of 466.Xr ntp.conf 5 . 467.Pp 468On each trusted host as root, change to the keys directory. 469To insure a fresh fileset, remove all 470.Cm ntpkey 471files. 472Then run 473.Nm 474.Fl T 475to generate keys and a trusted certificate. 476On all other hosts do the same, but leave off the 477.Fl T 478flag to generate keys and nontrusted certificates. 479When complete, start the NTP daemons beginning at the lowest stratum 480and working up the tree. 481It may take some time for Autokey to instantiate the certificate trails 482throughout the subnet, but setting up the environment is completely automatic. 483.Pp 484If it is necessary to use a different sign key or different digest/signature 485scheme than the default, run 486.Nm 487with the 488.Fl S Ar type 489option, where 490.Ar type 491is either 492.Cm RSA 493or 494.Cm DSA . 495The most often need to do this is when a DSA\-signed certificate is used. 496If it is necessary to use a different certificate scheme than the default, 497run 498.Nm 499with the 500.Fl c Ar scheme 501option and selected 502.Ar scheme 503as needed. 504f 505.Nm 506is run again without these options, it generates a new certificate 507using the same scheme and sign key. 508.Pp 509After setting up the environment it is advisable to update certificates 510from time to time, if only to extend the validity interval. 511Simply run 512.Nm 513with the same flags as before to generate new certificates 514using existing keys. 515However, if the host or sign key is changed, 516.Xr ntpd 8 517should be restarted. 518When 519.Xr ntpd 8 520is restarted, it loads any new files and restarts the protocol. 521Other dependent hosts will continue as usual until signatures are refreshed, 522at which time the protocol is restarted. 523.Ss Identity Schemes 524As mentioned on the Autonomous Authentication page, 525the default TC identity scheme is vulnerable to a middleman attack. 526However, there are more secure identity schemes available, 527including PC, IFF, GQ and MV described on the 528.Qq Identification Schemes 529page 530(maybe available at 531.Li http://www.eecis.udel.edu/%7emills/keygen.html ) . 532These schemes are based on a TA, one or more trusted hosts 533and some number of nontrusted hosts. 534Trusted hosts prove identity using values provided by the TA, 535while the remaining hosts prove identity using values provided 536by a trusted host and certificate trails that end on that host. 537The name of a trusted host is also the name of its sugroup 538and also the subject and issuer name on its trusted certificate. 539The TA is not necessarily a trusted host in this sense, but often is. 540.Pp 541In some schemes there are separate keys for servers and clients. 542A server can also be a client of another server, 543but a client can never be a server for another client. 544In general, trusted hosts and nontrusted hosts that operate 545as both server and client have parameter files that contain 546both server and client keys. 547Hosts that operate 548only as clients have key files that contain only client keys. 549.Pp 550The PC scheme supports only one trusted host in the group. 551On trusted host alice run 552.Nm 553.Fl P 554.Fl p Ar password 555to generate the host key file 556.Pa ntpkey_RSAkey_ Ns Ar alice.filestamp 557and trusted private certificate file 558.Pa ntpkey_RSA\-MD5_cert_ Ns Ar alice.filestamp . 559Copy both files to all group hosts; 560they replace the files which would be generated in other schemes. 561On each host bob install a soft link from the generic name 562.Pa ntpkey_host_ Ns Ar bob 563to the host key file and soft link 564.Pa ntpkey_cert_ Ns Ar bob 565to the private certificate file. 566Note the generic links are on bob, but point to files generated 567by trusted host alice. 568In this scheme it is not possible to refresh 569either the keys or certificates without copying them 570to all other hosts in the group. 571.Pp 572For the IFF scheme proceed as in the TC scheme to generate keys 573and certificates for all group hosts, then for every trusted host in the group, 574generate the IFF parameter file. 575On trusted host alice run 576.Nm 577.Fl T 578.Fl I 579.Fl p Ar password 580to produce her parameter file 581.Pa ntpkey_IFFpar_ Ns Ar alice.filestamp , 582which includes both server and client keys. 583Copy this file to all group hosts that operate as both servers 584and clients and install a soft link from the generic 585.Pa ntpkey_iff_ Ns Ar alice 586to this file. 587If there are no hosts restricted to operate only as clients, 588there is nothing further to do. 589As the IFF scheme is independent 590of keys and certificates, these files can be refreshed as needed. 591.Pp 592If a rogue client has the parameter file, it could masquerade 593as a legitimate server and present a middleman threat. 594To eliminate this threat, the client keys can be extracted 595from the parameter file and distributed to all restricted clients. 596After generating the parameter file, on alice run 597.Nm 598.Fl e 599and pipe the output to a file or mail program. 600Copy or mail this file to all restricted clients. 601On these clients install a soft link from the generic 602.Pa ntpkey_iff_ Ns Ar alice 603to this file. 604To further protect the integrity of the keys, 605each file can be encrypted with a secret password. 606.Pp 607For the GQ scheme proceed as in the TC scheme to generate keys 608and certificates for all group hosts, then for every trusted host 609in the group, generate the IFF parameter file. 610On trusted host alice run 611.Nm 612.Fl T 613.Fl G 614.Fl p Ar password 615to produce her parameter file 616.Pa ntpkey_GQpar_ Ns Ar alice.filestamp , 617which includes both server and client keys. 618Copy this file to all group hosts and install a soft link 619from the generic 620.Pa ntpkey_gq_ Ns Ar alice 621to this file. 622In addition, on each host bob install a soft link 623from generic 624.Pa ntpkey_gq_ Ns Ar bob 625to this file. 626As the GQ scheme updates the GQ parameters file and certificate 627at the same time, keys and certificates can be regenerated as needed. 628.Pp 629For the MV scheme, proceed as in the TC scheme to generate keys 630and certificates for all group hosts. 631For illustration assume trish is the TA, alice one of several trusted hosts 632and bob one of her clients. 633On TA trish run 634.Nm 635.Fl V Ar n 636.Fl p Ar password , 637where 638.Ar n 639is the number of revokable keys (typically 5) to produce 640the parameter file 641.Pa ntpkeys_MVpar_ Ns Ar trish.filestamp 642and client key files 643.Pa ntpkeys_MVkeyd_ Ns Ar trish.filestamp 644where 645.Ar d 646is the key number (0 \&< 647.Ar d 648\&< 649.Ar n ) . 650Copy the parameter file to alice and install a soft link 651from the generic 652.Pa ntpkey_mv_ Ns Ar alice 653to this file. 654Copy one of the client key files to alice for later distribution 655to her clients. 656It doesn't matter which client key file goes to alice, 657since they all work the same way. 658Alice copies the client key file to all of her cliens. 659On client bob install a soft link from generic 660.Pa ntpkey_mvkey_ Ns Ar bob 661to the client key file. 662As the MV scheme is independent of keys and certificates, 663these files can be refreshed as needed. 664.Ss Command Line Options 665.Bl -tag -width indent 666.It Fl c Ar scheme 667Select certificate message digest/signature encryption scheme. 668The 669.Ar scheme 670can be one of the following: 671. Cm RSA\-MD2 , RSA\-MD5 , RSA\-SHA , RSA\-SHA1 , RSA\-MDC2 , RSA\-RIPEMD160 , DSA\-SHA , 672or 673.Cm DSA\-SHA1 . 674Note that RSA schemes must be used with a RSA sign key and DSA 675schemes must be used with a DSA sign key. 676The default without this option is 677.Cm RSA\-MD5 . 678.It Fl d 679Enable debugging. 680This option displays the cryptographic data produced in eye\-friendly billboards. 681.It Fl e 682Write the IFF client keys to the standard output. 683This is intended for automatic key distribution by mail. 684.It Fl G 685Generate parameters and keys for the GQ identification scheme, 686obsoleting any that may exist. 687.It Fl g 688Generate keys for the GQ identification scheme 689using the existing GQ parameters. 690If the GQ parameters do not yet exist, create them first. 691.It Fl H 692Generate new host keys, obsoleting any that may exist. 693.It Fl I 694Generate parameters for the IFF identification scheme, 695obsoleting any that may exist. 696.It Fl i Ar name 697Set the suject name to 698.Ar name . 699This is used as the subject field in certificates 700and in the file name for host and sign keys. 701.It Fl M 702Generate MD5 keys, obsoleting any that may exist. 703.It Fl P 704Generate a private certificate. 705By default, the program generates public certificates. 706.It Fl p Ar password 707Encrypt generated files containing private data with 708.Ar password 709and the DES\-CBC algorithm. 710.It Fl q 711Set the password for reading files to password. 712.It Fl S Oo Cm RSA | DSA Oc 713Generate a new sign key of the designated type, 714obsoleting any that may exist. 715By default, the program uses the host key as the sign key. 716.It Fl s Ar name 717Set the issuer name to 718.Ar name . 719This is used for the issuer field in certificates 720and in the file name for identity files. 721.It Fl T 722Generate a trusted certificate. 723By default, the program generates a non\-trusted certificate. 724.It Fl V Ar nkeys 725Generate parameters and keys for the Mu\-Varadharajan (MV) identification scheme. 726.El 727.Ss Random Seed File 728All cryptographically sound key generation schemes must have means 729to randomize the entropy seed used to initialize 730the internal pseudo\-random number generator used 731by the library routines. 732The OpenSSL library uses a designated random seed file for this purpose. 733The file must be available when starting the NTP daemon and 734.Nm 735program. 736If a site supports OpenSSL or its companion OpenSSH, 737it is very likely that means to do this are already available. 738.Pp 739It is important to understand that entropy must be evolved 740for each generation, for otherwise the random number sequence 741would be predictable. 742Various means dependent on external events, such as keystroke intervals, 743can be used to do this and some systems have built\-in entropy sources. 744Suitable means are described in the OpenSSL software documentation, 745but are outside the scope of this page. 746.Pp 747The entropy seed used by the OpenSSL library is contained in a file, 748usually called 749.Cm .rnd , 750which must be available when starting the NTP daemon 751or the 752.Nm 753program. 754The NTP daemon will first look for the file 755using the path specified by the 756.Ic randfile 757subcommand of the 758.Ic crypto 759configuration command. 760If not specified in this way, or when starting the 761.Nm 762program, 763the OpenSSL library will look for the file using the path specified 764by the 765.Ev RANDFILE 766environment variable in the user home directory, 767whether root or some other user. 768If the 769.Ev RANDFILE 770environment variable is not present, 771the library will look for the 772.Cm .rnd 773file in the user home directory. 774If the file is not available or cannot be written, 775the daemon exits with a message to the system log and the program 776exits with a suitable error message. 777.Ss Cryptographic Data Files 778All other file formats begin with two lines. 779The first contains the file name, including the generated host name 780and filestamp. 781The second contains the datestamp in conventional Unix date format. 782Lines beginning with # are considered comments and ignored by the 783.Nm 784program and 785.Xr ntpd 8 786daemon. 787Cryptographic values are encoded first using ASN.1 rules, 788then encrypted if necessary, and finally written PEM\-encoded 789printable ASCII format preceded and followed by MIME content identifier lines. 790.Pp 791The format of the symmetric keys file is somewhat different 792than the other files in the interest of backward compatibility. 793Since DES\-CBC is deprecated in NTPv4, the only key format of interest 794is MD5 alphanumeric strings. 795Following hte heard the keys are 796entered one per line in the format 797.D1 Ar keyno type key 798where 799.Ar keyno 800is a positive integer in the range 1\-65,535, 801.Ar type 802is the string MD5 defining the key format and 803.Ar key 804is the key itself, 805which is a printable ASCII string 16 characters or less in length. 806Each character is chosen from the 93 printable characters 807in the range 0x21 through 0x7f excluding space and the 808.Ql # 809character. 810.Pp 811Note that the keys used by the 812.Xr ntpq 8 813and 814.Xr ntpdc 8 815programs 816are checked against passwords requested by the programs 817and entered by hand, so it is generally appropriate to specify these keys 818in human readable ASCII format. 819.Pp 820The 821.Nm 822program generates a MD5 symmetric keys file 823.Pa ntpkey_MD5key_ Ns Ar hostname.filestamp . 824Since the file contains private shared keys, 825it should be visible only to root and distributed by secure means 826to other subnet hosts. 827The NTP daemon loads the file 828.Pa ntp.keys , 829so 830.Nm 831installs a soft link from this name to the generated file. 832Subsequently, similar soft links must be installed by manual 833or automated means on the other subnet hosts. 834While this file is not used with the Autokey Version 2 protocol, 835it is needed to authenticate some remote configuration commands 836used by the 837.Xr ntpq 8 838and 839.Xr ntpdc 8 840utilities. 841.Sh "OPTIONS" 842.Bl -tag 843.It Fl b Ar imbits , Fl \-imbits Ns = Ns Ar imbits 844identity modulus bits. 845This option takes an integer number as its argument. 846The value of 847.Ar imbits 848is constrained to being: 849.in +4 850.nf 851.na 852in the range 256 through 2048 853.fi 854.in -4 855.sp 856The number of bits in the identity modulus. The default is 256. 857.It Fl c Ar scheme , Fl \-certificate Ns = Ns Ar scheme 858certificate scheme. 859.sp 860scheme is one of 861RSA\-MD2, RSA\-MD5, RSA\-SHA, RSA\-SHA1, RSA\-MDC2, RSA\-RIPEMD160, 862DSA\-SHA, or DSA\-SHA1. 863.sp 864Select the certificate message digest/signature encryption scheme. 865Note that RSA schemes must be used with a RSA sign key and DSA 866schemes must be used with a DSA sign key. The default without 867this option is RSA\-MD5. 868.It Fl C Ar cipher , Fl \-cipher Ns = Ns Ar cipher 869privatekey cipher. 870.sp 871Select the cipher which is used to encrypt the files containing 872private keys. The default is three\-key triple DES in CBC mode, 873equivalent to "@code{\-C des\-ede3\-cbc". The openssl tool lists ciphers 874available in "\fBopenssl \-h\fP" output. 875.It Fl d , Fl \-debug\-level 876Increase debug verbosity level. 877This option may appear an unlimited number of times. 878.sp 879.It Fl D Ar number , Fl \-set\-debug\-level Ns = Ns Ar number 880Set the debug verbosity level. 881This option may appear an unlimited number of times. 882This option takes an integer number as its argument. 883.sp 884.It Fl e , Fl \-id\-key 885Write IFF or GQ identity keys. 886.sp 887Write the IFF or GQ client keys to the standard output. This is 888intended for automatic key distribution by mail. 889.It Fl G , Fl \-gq\-params 890Generate GQ parameters and keys. 891.sp 892Generate parameters and keys for the GQ identification scheme, 893obsoleting any that may exist. 894.It Fl H , Fl \-host\-key 895generate RSA host key. 896.sp 897Generate new host keys, obsoleting any that may exist. 898.It Fl I , Fl \-iffkey 899generate IFF parameters. 900.sp 901Generate parameters for the IFF identification scheme, obsoleting 902any that may exist. 903.It Fl i Ar group , Fl \-ident Ns = Ns Ar group 904set Autokey group name. 905.sp 906Set the optional Autokey group name to name. This is used in 907the file name of IFF, GQ, and MV client parameters files. In 908that role, the default is the host name if this option is not 909provided. The group name, if specified using \fB\-i/\-\-ident\fP or 910using \fB\-s/\-\-subject\-name\fP following an '\fB@\fP' character, 911is also a part of the self\-signed host certificate's subject and 912issuer names in the form \fBhost@group\fP and should match the 913\'\fBcrypto ident\fP' or '\fBserver ident\fP' configuration in 914\fBntpd\fP's configuration file. 915.It Fl l Ar lifetime , Fl \-lifetime Ns = Ns Ar lifetime 916set certificate lifetime. 917This option takes an integer number as its argument. 918.sp 919Set the certificate expiration to lifetime days from now. 920.It Fl M , Fl \-md5key 921generate MD5 keys. 922.sp 923Generate MD5 keys, obsoleting any that may exist. 924.It Fl m Ar modulus , Fl \-modulus Ns = Ns Ar modulus 925modulus. 926This option takes an integer number as its argument. 927The value of 928.Ar modulus 929is constrained to being: 930.in +4 931.nf 932.na 933in the range 256 through 2048 934.fi 935.in -4 936.sp 937The number of bits in the prime modulus. The default is 512. 938.It Fl P , Fl \-pvt\-cert 939generate PC private certificate. 940.sp 941Generate a private certificate. By default, the program generates 942public certificates. 943.It Fl p Ar passwd , Fl \-password Ns = Ns Ar passwd 944local private password. 945.sp 946Local files containing private data are encrypted with the 947DES\-CBC algorithm and the specified password. The same password 948must be specified to the local ntpd via the "crypto pw password" 949configuration command. The default password is the local 950hostname. 951.It Fl q Ar passwd , Fl \-export\-passwd Ns = Ns Ar passwd 952export IFF or GQ group keys with password. 953.sp 954Export IFF or GQ identity group keys to the standard output, 955encrypted with the DES\-CBC algorithm and the specified password. 956The same password must be specified to the remote ntpd via the 957"crypto pw password" configuration command. See also the option 958-\-id\-key (\-e) for unencrypted exports. 959.It Fl S Ar sign , Fl \-sign\-key Ns = Ns Ar sign 960generate sign key (RSA or DSA). 961.sp 962Generate a new sign key of the designated type, obsoleting any 963that may exist. By default, the program uses the host key as the 964sign key. 965.It Fl s Ar host@group , Fl \-subject\-name Ns = Ns Ar host@group 966set host and optionally group name. 967.sp 968Set the Autokey host name, and optionally, group name specified 969following an '\fB@\fP' character. The host name is used in the file 970name of generated host and signing certificates, without the 971group name. The host name, and if provided, group name are used 972in \fBhost@group\fP form for the host certificate's subject and issuer 973fields. Specifying '\fB\-s @group\fP' is allowed, and results in 974leaving the host name unchanged while appending \fB@group\fP to the 975subject and issuer fields, as with \fB\-i group\fP. The group name, or 976if not provided, the host name are also used in the file names 977of IFF, GQ, and MV client parameter files. 978.It Fl T , Fl \-trusted\-cert 979trusted certificate (TC scheme). 980.sp 981Generate a trusted certificate. By default, the program generates 982a non\-trusted certificate. 983.It Fl V Ar num , Fl \-mv\-params Ns = Ns Ar num 984generate <num> MV parameters. 985This option takes an integer number as its argument. 986.sp 987Generate parameters and keys for the Mu\-Varadharajan (MV) 988identification scheme. 989.It Fl v Ar num , Fl \-mv\-keys Ns = Ns Ar num 990update <num> MV keys. 991This option takes an integer number as its argument. 992.sp 993This option has not been fully documented. 994.It Fl \&? , Fl \-help 995Display usage information and exit. 996.It Fl \&! , Fl \-more\-help 997Pass the extended usage information through a pager. 998.It Fl > Oo Ar cfgfile Oc , Fl \-save\-opts Oo Ns = Ns Ar cfgfile Oc 999Save the option state to \fIcfgfile\fP. The default is the \fIlast\fP 1000configuration file listed in the \fBOPTION PRESETS\fP section, below. 1001The command will exit after updating the config file. 1002.It Fl < Ar cfgfile , Fl \-load\-opts Ns = Ns Ar cfgfile , Fl \-no\-load\-opts 1003Load options from \fIcfgfile\fP. 1004The \fIno\-load\-opts\fP form will disable the loading 1005of earlier config/rc/ini files. \fI\-\-no\-load\-opts\fP is handled early, 1006out of order. 1007.It Fl \-version Op Brq Ar v|c|n 1008Output version of program and exit. The default mode is `v', a simple 1009version. The `c' mode will print copyright information and `n' will 1010print the full copyright notice. 1011.El 1012.Sh "OPTION PRESETS" 1013Any option that is not marked as \fInot presettable\fP may be preset 1014by loading values from configuration ("RC" or ".INI") file(s) and values from 1015environment variables named: 1016.nf 1017 \fBNTP_KEYGEN_<option\-name>\fP or \fBNTP_KEYGEN\fP 1018.fi 1019.ad 1020The environmental presets take precedence (are processed later than) 1021the configuration files. 1022The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP". 1023If any of these are directories, then the file \fI.ntprc\fP 1024is searched for within those directories. 1025.Sh USAGE 1026The 1027.Fl p Ar password 1028option specifies the write password and 1029.Fl q Ar password 1030option the read password for previously encrypted files. 1031The 1032.Nm 1033program prompts for the password if it reads an encrypted file 1034and the password is missing or incorrect. 1035If an encrypted file is read successfully and 1036no write password is specified, the read password is used 1037as the write password by default. 1038.Sh "ENVIRONMENT" 1039See \fBOPTION PRESETS\fP for configuration environment variables. 1040.Sh "FILES" 1041See \fBOPTION PRESETS\fP for configuration files. 1042.Sh "EXIT STATUS" 1043One of the following exit values will be returned: 1044.Bl -tag 1045.It 0 " (EXIT_SUCCESS)" 1046Successful program execution. 1047.It 1 " (EXIT_FAILURE)" 1048The operation failed or the command syntax was not valid. 1049.It 66 " (EX_NOINPUT)" 1050A specified configuration file could not be loaded. 1051.It 70 " (EX_SOFTWARE)" 1052libopts had an internal operational error. Please report 1053it to autogen\-users@lists.sourceforge.net. Thank you. 1054.El 1055.Sh "AUTHORS" 1056The University of Delaware and Network Time Foundation 1057.Sh "COPYRIGHT" 1058Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved. 1059This program is released under the terms of the NTP license, <http://ntp.org/license>. 1060.Sh BUGS 1061It can take quite a while to generate some cryptographic values, 1062from one to several minutes with modern architectures 1063such as UltraSPARC and up to tens of minutes to an hour 1064with older architectures such as SPARC IPC. 1065.Pp 1066Please report bugs to http://bugs.ntp.org . 1067.Pp 1068Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org 1069.Sh NOTES 1070Portions of this document came from FreeBSD. 1071.Pp 1072This manual page was \fIAutoGen\fP\-erated from the \fBntp\-keygen\fP 1073option definitions. 1074