NTP_KEYGEN(8)

๐Ÿ“ฆ
version 4.2.8p15 ยท 3 versions
, in ubuntu jammy

๐Ÿ’– NAME ๐Ÿ’–

ntp-keygen โ€” bestie, this is the one that creates your NTP host key. โœจ

No cap, that's literally the whole job description.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

ntp-keygen [-flags] [-flag [value]] [--option-name[[=| ]value]]
โš ๏ธ Heads up, queen: All arguments must be options. There's no "here's a random filename, go wild" energy here. Options only. Periodt. ๐Ÿ’…

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so. ntp-keygen is the little program that makes all the cryptographic data files that the NTPv4 authentication and identification schemes eat for breakfast. It can generate message digest keys used in symmetric key cryptography, and โ€” if the OpenSSL software library has been installed โ€” it can also generate host keys, signing keys, certificates, and identity keys and parameters used in Autokey public key cryptography. These files are what power cookie encryption, digital signature, and challenge/response identification algorithms, all compatible with the Internet standard security infrastructure. She's giving โœจcertified infrastructure iconโœจ.

The message digest symmetric keys file gets generated in a format compatible with NTPv3. Everything else is in PEM-encoded printable ASCII format, so you can literally embed them as MIME attachments in email to other sites and certificate authorities. Cute, portable, mail-able. ๐Ÿ“ง And by default? Files are not encrypted. Just out there. Naked. ๐Ÿ™ˆ

When you use it to generate message digest symmetric keys, the program produces a file containing ten pseudo-random printable ASCII strings suitable for the MD5 message digest algorithm included in the distribution. And if the OpenSSL library is installed, it produces an additional ten hex-encoded random bit strings suitable for SHA1, AES-128-CMAC, and other message digest algorithms. Obsessed with options honestly.

๐Ÿšจ The message digest symmetric keys file must be distributed and stored using secure means beyond the scope of NTP itself. That's on you, babe. NTP is not your bodyguard for that part.

Besides the keys used for ordinary NTP associations, additional keys can be defined as passwords for the ntpq(1) and ntpdc(1) utility programs. Multi-purpose keys, we love to see it. ๐Ÿ”‘

The remaining generated files are compatible with other OpenSSL applications and other Public Key Infrastructure (PKI) resources. Certificates generated by this program are compatible with extant industry practice, although some users might find the interpretation of X509v3 extension fields somewhat liberal. (She's a little free-spirited with the extension fields, iykyk.) However โ€” and this is important โ€” the identity keys are probably not compatible with anything other than Autokey. She's niche. She's exclusive. ๐Ÿ’…


Some files used by this program are encrypted using a private password. The -p option specifies the read password for local encrypted files, and the -q option the write password for encrypted files sent to remote sites. If no password is specified, the host name returned by the Unix hostname(1) command โ€” normally the DNS name of the host โ€” is used as the default read password, for convenience. ๐ŸŽ€

The ntp-keygen program prompts for the password if it reads an encrypted file and the password is missing or incorrect. And if an encrypted file is read successfully and no write password is specified, the read password is used as the write password by default. Symmetry, slay. โœจ

The pw option of the crypto ntpd(8) configuration command specifies the read password for previously encrypted local files. This must match the local read password used by this program. If not specified, the host name is used. So like: if files are generated by this program without an explicit password, they can be read back by ntpd(8) without specifying an explicit password โ€” but only on the same host. And if the write password used for encryption is specified as the host name, these files can be read by that host with no explicit password. No cap, that's the whole mechanic. ๐Ÿซถ

Normally, encrypted files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page. The symmetric keys file, normally called ntp.keys, is usually installed in /etc. Other files and links are usually installed in /usr/local/etc, which is normally in a shared filesystem in NFS-mounted networks and cannot be changed by shared clients. In these cases, NFS clients can specify the files in another directory such as /etc using the keysdir ntpd(8) configuration file command. ๐ŸŒˆ

This program directs commentary and error messages to the standard error stream stderr and remote files to the standard output stream stdout, where they can be piped to other applications or redirected to files. The names used for generated files and links all begin with the string ntpkey* and include the file type, generating host and filestamp, as described in the โ€œCryptographic Data Filesโ€ section below. โœจ


๐Ÿ‘‘ Running the Program ๐Ÿ‘‘

The safest way to run the ntp-keygen program is logged in directly as root. The recommended procedure is: change to the keys directory, usually /usr/local/etc, then run the program. Simple. Elegant. Root-coded. ๐Ÿ”ฅ

To test and gain experience with Autokey concepts, log in as root and change to the keys directory, usually /usr/local/etc. When run for the first time, or if all files with names beginning with ntpkey* have been removed, use the ntp-keygen command without arguments to generate a default RSA host key and matching RSA-MD5 certificate file with expiration date one year hence, which is all that is necessary in many cases. The program also generates soft links from the generic names to the respective files. And if you run it again without options? The program uses the existing keys and parameters and generates a new certificate file with new expiration date one year hence, and soft link. Regeneration queen. ๐Ÿงš

The host key is used to encrypt the cookie when required and so must be RSA type. By default, the host key is also the sign key used to encrypt signatures. When necessary, a different sign key can be specified, and this can be either RSA or DSA type. By default, the message digest type is MD5, but any combination of sign key type and message digest type supported by the OpenSSL library can be specified โ€” including those using the AES128CMAC, MD2, MD5, MDC2, SHA, SHA1 and RIPE160 message digest algorithms. ๐ŸŽ€

โš ๏ธ But listen: the scheme specified in the certificate must be compatible with the sign key. Certificates using any digest algorithm are compatible with RSA sign keys; however, only SHA and SHA1 certificates are compatible with DSA sign keys. Don't mix and match and then act surprised. ๐Ÿ˜ญ

Private/public key files and certificates are compatible with other OpenSSL applications and very likely other libraries as well. Certificates or certificate requests derived from them should be compatible with extant industry practice, although some users might find the interpretation of X509v3 extension fields somewhat liberal. (Again. She's an artist. ๐ŸŽจ) However, the identification parameter files, although encoded as the other files, are probably not compatible with anything other than Autokey.

Running the program as other than root and using the Unix su(1) command to assume root may not work properly, since by default the OpenSSL library looks for the random seed file .rnd in the user home directory. However, there should be only one .rnd, most conveniently in the root directory, so it is convenient to define the RANDFILE environment variable used by the OpenSSL library as the path to .rnd. One .rnd. One truth. ๐Ÿ’œ

Installing the keys as root might not work in NFS-mounted shared file systems, as NFS clients may not be able to write to the shared keys directory, even as root. In this case, NFS clients can specify the files in another directory such as /etc using the keysdir ntpd(8) configuration file command. There is no need for one client to read the keys and certificates of other clients or servers, as these data are obtained automatically by the Autokey protocol. Autokey handles it. She's self-sufficient. ๐Ÿ’…

Ordinarily, cryptographic files are generated by the host that uses them, but it is possible for a trusted agent (TA) to generate these files for other hosts; however, in such cases files should always be encrypted. The subject name and trusted name default to the hostname of the host generating the files, but can be changed by command line options. It is convenient to designate the owner name and trusted name as the subject and issuer fields, respectively, of the certificate. The owner name is also used for the host and sign key files, while the trusted name is used for the identity files. ๐Ÿฆ‹

All files are installed by default in the keys directory /usr/local/etc, which is normally in a shared filesystem in NFS-mounted networks. The actual location of the keys directory and each file can be overridden by configuration commands, but this is not recommended. Normally, the files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page.

Normally, files containing private values โ€” including the host key, sign key and identification parameters โ€” are permitted root read/write-only; while others containing public values are permitted world readable. Alternatively, files containing private values can be encrypted and these files permitted world readable, which simplifies maintenance in shared file systems. Since uniqueness is insured by the hostname and filestamp file name extensions, the files for an NTP server and dependent clients can all be installed in the same shared directory. Everybody in one house, nobody confused about who's who. ๐Ÿ โœจ

The recommended practice is to keep the file name extensions when installing a file, and to install a soft link from the generic names specified elsewhere on this page to the generated files. This allows new file generations to be activated simply by changing the link. If a link is present, ntpd(8) follows it to the file name to extract the filestamp. If a link is not present, ntpd(8) extracts the filestamp from the file itself. This allows clients to verify that the file and generation times are always current. The ntp-keygen program uses the same filestamp extension for all files generated at one time, so each generation is distinct and can be readily recognized in monitoring data. โญ

Run the command on as many hosts as necessary. Designate one of them as the trusted host (TH) using ntp-keygen with the -T option and configure it to synchronize from reliable Internet servers. Then configure the other hosts to synchronize to the TH directly or indirectly. A certificate trail is created when Autokey asks the immediately ascendant host towards the TH to sign its certificate, which is then provided to the immediately descendant host on request. All group hosts should have acyclic certificate trails ending on the TH. ๐ŸŒ€

The host key is used to encrypt the cookie when required and so must be RSA type. By default, the host key is also the sign key used to encrypt signatures. A different sign key can be assigned using the -S option, and this can be either RSA or DSA type. By default, the signature message digest type is MD5, but any combination of sign key type and message digest type supported by the OpenSSL library can be specified using the -c option. ๐Ÿ”ฅ


The rules say crypto media should be generated with proventic filestamps, which lowkey means the host should already be synchronized before this program is even run. Which, yeah, creates a whole chicken-and-egg situation the very first time a host boots up ๐Ÿ™ˆ. So accordingly: set the host time by some other means โ€” eyeball-and-wristwatch energy, literally looking at your watch โ€” at least so the certificate lifetime lands inside the current year. After that, once the host is synchronized to a proventic source, regenerate that certificate. No cap.

Additional info on trusted groups and identity schemes lives on the โ€œAutokey Public-Key Authenticationโ€ page. ๐Ÿฆ‹

File names begin with the prefix ntpkey_ and end with the suffix _hostname.filestamp, where hostname is the owner name โ€” usually the string the Unix hostname(1) command returns โ€” and filestamp is the NTP seconds when the file was generated, in decimal digits. This both guarantees uniqueness and simplifies maintenance, because you can wipe every file with a quick rm ntpkey*, or clear out everything generated at one specific time with rm *filestamp. Periodt. ๐Ÿ’… To reduce the risk of misconfiguration even further, the first two lines of a file contain the file name and generation date and time as comments.

๐ŸŒธ Trusted Hosts and Groups ๐ŸŒธ

Every cryptographic configuration involves picking a signature scheme and an identification scheme, together called a cryptotype, as explained in the โ€œAuthentication Optionsโ€ section of ntp.conf(5). The default cryptotype uses RSA encryption, MD5 message digest and TC identification. So first: configure an NTP subnet including one or more low-stratum trusted hosts, from which all the other hosts derive synchronization directly or indirectly. Trusted hosts have trusted certificates; all the other hosts have nontrusted certificates. These hosts automatically and dynamically build authoritative certificate trails to one or more trusted hosts. A trusted group is the set of all hosts that have, directly or indirectly, a certificate trail ending at a trusted host. The trail is defined by static configuration file entries or by the dynamic means described in the โ€œAutomatic NTP Configuration Optionsโ€ section of ntp.conf(5).

On each trusted host, as root, change into the keys directory. To insure a fresh fileset, remove all ntpkey files. Then run ntp-keygen -T to generate keys and a trusted certificate. On all the other hosts do the same thing, but leave off the -T flag, so you generate keys and nontrusted certificates instead. When you're done, start the NTP daemons beginning at the lowest stratum and working up the tree. Autokey may take some time to instantiate the certificate trails throughout the subnet, but setting up the environment is completely automatic. Slay. โœจ

If you need a different sign key or a different digest/signature scheme than the default, run ntp-keygen with the -S type option, where type is either RSA or DSA. The most frequent reason to do this is when a DSA-signed certificate is used. If you need a different certificate scheme than the default, run ntp-keygen with the -c scheme option and the selected scheme as needed. If ntp-keygen is run again without these options, it generates a new certificate using the same scheme and sign key, and soft link.

After setting up the environment it's advisable to update certificates from time to time, if only to extend the validity interval. Just run ntp-keygen with the same flags as before to generate new certificates using existing keys, and soft links. However, if the host or sign key is changed, ntpd(8) should be restarted. When ntpd(8) is restarted, it loads any new files and restarts the protocol. Other dependent hosts will continue as usual until signatures are refreshed, at which time the protocol is restarted. ๐Ÿ”ฅ

๐ŸŽ€ Identity Schemes ๐ŸŽ€

As mentioned on the Autonomous Authentication page, the default TC identity scheme is vulnerable to a middleman attack. ๐Ÿ˜ญ But bestie, there are more secure identity schemes available, including the PC, IFF, GQ and MV schemes described below. These schemes are based on a TA, one or more trusted hosts and some number of nontrusted hosts. Trusted hosts prove identity using values provided by the TA, while the remaining hosts prove identity using values provided by a trusted host and certificate trails that end on that host. The name of a trusted host is also the name of its sugroup and also the subject and issuer name on its trusted certificate. The TA is not necessarily a trusted host in this sense, but often is.

In some schemes there are separate keys for servers and clients. A server can also be a client of another server, but a client can never be a server for another client. In general, trusted hosts and nontrusted hosts that operate as both server and client have parameter files that contain both server and client keys. Hosts that operate only as clients have key files that contain only client keys.

The PC scheme supports only one trusted host in the group. On trusted host alice run ntp-keygen -P -p password to generate the host key file ntpkey_RSAkey_alice.filestamp and trusted private certificate file ntpkey_RSA-MD5_cert_alice.filestamp, and soft links. Copy both files to all group hosts; they replace the files which would be generated in other schemes. On each host bob, install a soft link from the generic name ntpkey_host_bob to the host key file, and soft link ntpkey_cert_bob to the private certificate file. Note that the generic links are on bob, but they point to files generated by trusted host alice. In this scheme it is not possible to refresh either the keys or certificates without copying them to all other hosts in the group, and recreating the soft links. ๐Ÿ’€

For the IFF scheme proceed as in the TC scheme to generate keys and certificates for all group hosts, then for every trusted host in the group, generate the IFF parameter file. On trusted host alice run ntp-keygen -T -I -p password to produce her parameter file ntpkey_IFFpar_alice.filestamp, which includes both server and client keys. Copy this file to all group hosts that operate as both servers and clients, and install a soft link from the generic ntpkey_iff_alice to this file. If there are no hosts restricted to operate only as clients, there is nothing further to do. Since the IFF scheme is independent of keys and certificates, these files can be refreshed as needed. ๐Ÿฆ‹

If a rogue client has the parameter file, it could masquerade as a legitimate server and present a middleman threat. To eliminate this threat, the client keys can be extracted from the parameter file and distributed to all restricted clients. After generating the parameter file, on alice run ntp-keygen -e and pipe the output to a file or email program. Copy or email this file to all restricted clients. On these clients install a soft link from the generic ntpkey_iff_alice to this file. To further protect the integrity of the keys, each file can be encrypted with a secret password. ๐Ÿ”

For the GQ scheme proceed as in the TC scheme to generate keys and certificates for all group hosts, then for every trusted host in the group, generate the IFF parameter file. On trusted host alice run ntp-keygen -T -G -p password to produce her parameter file ntpkey_GQpar_alice.filestamp, which includes both server and client keys. Copy this file to all group hosts and install a soft link from the generic ntpkey_gq_alice to this file. In addition, on each host bob install a soft link from generic ntpkey_gq_bob to this file. Since the GQ scheme updates the GQ parameters file and certificate at the same time, keys and certificates can be regenerated as needed.

For the MV scheme, proceed as in the TC scheme to generate keys and certificates for all group hosts. For illustration, assume trish is the TA, alice one of several trusted hosts and bob one of her clients. On TA trish run ntp-keygen -V n -p password, where n is the number of revokable keys (typically 5) to produce the parameter file ntpkeys_MVpar_trish.filestamp and client key files ntpkeys_MVkeyd_trish.filestamp, where d is the key number (0 < d < n). Copy the parameter file to alice and install a soft link from the generic ntpkey_mv_alice to this file. Copy one of the client key files to alice for later distribution to her clients. It does not matter which client key file goes to alice, since they all work the same way. Alice copies the client key file to all of her clients. On client bob install a soft link from generic ntpkey_mvkey_bob to the client key file. Since the MV scheme is independent of keys and certificates, these files can be refreshed as needed. ๐ŸŒˆ

๐Ÿ‘‘ Command Line Options ๐Ÿ‘‘

  • -b, --imbits=modulus โ€” set the number of bits in the identity modulus for generating identity keys to modulus bits. The number of bits in the identity modulus defaults to 256, but can be set to values from 256 to 2048 (that's 32 to 256 octets). Use the larger moduli with caution โ€” this can consume considerable computing resources and increases the size of authenticated packets. ๐Ÿ˜ฎโ€๐Ÿ’จ
  • -c, --certificate=scheme โ€” select the certificate signature encryption/message digest scheme. scheme can be one of the following: RSA-MD2, RSA-MD5, RSA-MDC2, RSA-SHA, RSA-SHA1, RSA-RIPEMD160, DSA-SHA, or DSA-SHA1. Note that RSA schemes must be used with an RSA sign key and DSA schemes must be used with a DSA sign key. The default without this option is RSA-MD5. If compatibility with FIPS 140-2 is required, either the DSA-SHA or DSA-SHA1 scheme must be used. ๐Ÿ“œ
  • -C, --cipher=cipher โ€” select the OpenSSL cipher to encrypt the files containing private keys. The default without this option is three-key triple DES in CBC mode, des-ede3-cbc. The openssl -h command provided with OpenSSL displays available ciphers. ๐Ÿ”’
  • -d, --debug-level โ€” increase the debugging verbosity level. This option displays the cryptographic data produced in eye-friendly billboards. ๐Ÿ‘€
  • -D, --set-debug-level=level โ€” set the debugging verbosity to level. This option displays the cryptographic data produced in eye-friendly billboards.
  • -e, --id-key โ€” write the IFF or GQ public parameters from the IFFkey or GQkey client keys file previously specified as unencrypted data to the standard output stream stdout. This is intended for automatic key distribution by email. ๐Ÿ’Œ
  • -G, --gq-params โ€” generate a new encrypted GQ parameters and key file for the Guillou-Quisquater (GQ) identity scheme. This option is mutually exclusive with the -I and -V options. ๐Ÿ™…โ€โ™€๏ธ
  • -H, --host-key โ€” generate a new encrypted RSA public/private host key file. ๐Ÿ”‘
  • -I, --iffkey โ€” makes you a brand new encrypted IFF key file for the Schnorr (IFF) identity scheme ๐Ÿฆ‹. Heads up bestie: this one is mutually exclusive with the -G and -V options, so pick your lane.
  • -i, --ident= group โ€” sets the optional Autokey group name to group. This is the thing that shows up in the identity scheme parameter file names for IFF, GQ and MV client parameters files โœจ. In that role, if you don't hand it a group, the default is just the host name. And if you specify the group name via -i or via -s after an โ€˜@โ€™ character, it also gets used in certificate subject and issuer names in the form host @ group, and it should match the group you set with crypto ident or server ident in the ntpd configuration file. Consistency is the vibe ๐Ÿ’….
  • -l, --lifetime= days โ€” sets how long until the certificate expires, in days. Default lifetime is one year (365 days), no cap ๐ŸŽ€.
  • -m, --modulus= bits โ€” sets the number of bits in the prime modulus for generating files to bits. Modulus defaults to 512, but you can go from 256 to 2048 (32 to 256 octets). โš ๏ธ Use the larger moduli with caution, because this can consume considerable computing resources and increases the size of authenticated packets. Big modulus, big consequences, fr fr.
  • -M, --md5key โ€” generates a new symmetric keys file containing 10 MD5 keys, plus 10 SHA keys if OpenSSL is available. An MD5 key is a string of 20 random printable ASCII characters, while a SHA key is a string of 40 random hex digits. You can edit the file with a text editor to change the key type or the key content ๐Ÿ”ฅ. This option is mutually exclusive with all other options โ€” it's the main character, it doesn't share the spotlight ๐Ÿ‘‘.
  • -p, --password= passwd โ€” sets the password for reading and writing encrypted files to passwd. These include the host, sign and identify key files ๐Ÿ”. By default, the password is the string returned by the Unix hostname command.
  • -P, --pvt-cert โ€” generates a new private certificate used by the PC identity scheme. By default the program generates public certificates. Note: the PC identity scheme is not recommended for new installations ๐Ÿ’€.
  • -q, --export-passwd= passwd โ€” sets the password for writing encrypted IFF, GQ and MV identity files redirected to stdout to passwd. In effect, these files get decrypted with the -p password, then encrypted with the -q password ๐Ÿงš. By default, the password is the string returned by the Unix hostname command.
  • -s, --subject-key= file ... [host] [@ group] โ€” specify the Autokey host name, where host is the optional host name and group is the optional group name. The host name, and the group name if provided, get used in host @ group form as certificate subject and issuer ๐ŸŒธ. Specifying -s -@ group is allowed, and results in leaving the host name unchanged, same as with -i group. The group name, or the host name if no group is provided, is also used in the file names of IFF, GQ and MV identity scheme client parameter files. If host isn't specified, the default host name is the string returned by the Unix hostname command.
  • -S, --sign-key= [RSA | DSA] โ€” generates a new encrypted public/private sign key file of the type you picked โœจ. By default, the sign key is the host key and has the same type. If you need compatibility with FIPS 140-2, the sign key type must be DSA โญ.
  • -T, --trusted-cert โ€” generates a trusted certificate. By default, the program generates a non-trusted certificate.
  • -V, --mv-params nkeys โ€” generates nkeys encrypted server keys and parameters for the Mu-Varadharajan (MV) identity scheme. This option is mutually exclusive with the -I and -G options ๐Ÿ™ˆ. Note: support for this option should be considered a work in progress.

๐ŸŽ€ Random Seed File ๐ŸŽ€

Okay so every cryptographically sound key generation scheme has to have some way to randomize the entropy seed that initializes the internal pseudo-random number generator the library routines use ๐Ÿ’œ. The OpenSSL library uses a designated random seed file for exactly this. That file must be available when you start the NTP daemon and the ntp-keygen program. And honestly, if a site supports OpenSSL or its companion OpenSSH, there's a very good chance the means to do this are already sitting there.

It is important to understand that entropy must be evolved for each generation, because otherwise the random number sequence would be predictable ๐Ÿ˜ญ. Various means that depend on external events โ€” keystroke intervals and stuff like that โ€” can be used to do this, and some systems have built-in entropy sources. Suitable means are described in the OpenSSL software documentation, but they're outside the scope of this page.

The entropy seed used by the OpenSSL library lives in a file, usually called .rnd, which must be available when starting the NTP daemon or the ntp-keygen program. The NTP daemon will first look for the file using the path specified by the randfile subcommand of the crypto configuration command ๐Ÿฆ‹. If it's not specified that way, or when starting the ntp-keygen program, the OpenSSL library will look for the file using the path specified by the RANDFILE environment variable in the user home directory, whether root or some other user. If the RANDFILE environment variable is not present, the library will look for the .rnd file in the user home directory. Since both the ntp-keygen program and the ntpd(8) daemon must run as root, the logical place to put this file is in /.rnd or /root/.rnd ๐Ÿ‘‘. If the file isn't available or can't be written, the daemon exits with a message to the system log and the program exits with a suitable error message ๐Ÿ’€.


๐ŸŒธ Cryptographic Data Files ๐ŸŒธ

All file formats begin with two nonencrypted lines โœจ. The first line contains the file name, including the generated host name and filestamp, in the format

ntpkey_key _ name. filestamp

where key is the key or parameter type, name is the host or group name and filestamp is the filestamp (NTP seconds) when the file was created. By convention, key names in generated file names include both upper and lower case characters, while key names in generated link names include only lower case characters ๐Ÿ”ค. The filestamp is not used in generated link names. The second line contains the datestamp in conventional Unix date format. Lines beginning with โ€˜#โ€™ are considered comments and ignored by the ntp-keygen program and the ntpd(8) daemon.

The remainder of the file contains cryptographic data, encoded first using ASN.1 rules, then encrypted if necessary, and finally written in PEM-encoded printable ASCII text, preceded and followed by MIME content identifier lines ๐Ÿ’….

The format of the symmetric keys file, ordinarily named ntp.keys, is somewhat different than the other files in the interest of backward compatibility. Ordinarily, the file is generated by this program, but it can be constructed and edited using an ordinary text editor.

                         # ntpkey_MD5key_bk.ntp.org.3595864945
                         # Thu Dec 12 19:22:25 2013
                         1  MD5 L";Nw<`.I<f4U0)247"i  # MD5 key
                         2  MD5 &>l0%XXK9O'51VwV<xq~  # MD5 key
                         3  MD5 lb4zLW~d^!K:]RsD'qb6  # MD5 key
                         4  MD5 Yue:tL[+vR)M`n~bY,'?  # MD5 key
                         5  MD5 B;fx'Kgr/&4ZTbL6=RxA  # MD5 key
                         6  MD5 4eYwa`o}3i@@V@..R9!l  # MD5 key
                         7  MD5 `A.([h+;wTQ|xfi%Sn_!  # MD5 key
                         8  MD5 45:V,r4]l6y^JH6"Sh?F  # MD5 key
                         9  MD5 3-5vcn*6l29DS?Xdsg)*  # MD5 key
                         10 MD5 2late4Me              # MD5 key
                         11 SHA1 a27872d3030a9025b8446c751b4551a7629af65c  # SHA1 key
                         12 SHA1 21bc3b4865dbb9e920902abdccb3e04ff97a5e74  # SHA1 key
                         13 SHA1 2b7736fe24fef5ba85ae11594132ab5d6f6daba9  # SHA1 key
                         14 SHA  a5332809c8878dd3a5b918819108a111509aeceb  # SHA  key
                         15 MD2  2fe16c88c760ff2f16d4267e36c1aa6c926e6964  # MD2  key
                         16 MD4  b2691811dc19cfc0e2f9bcacd74213f29812183d  # MD4  key
                         17 MD5  e4d6735b8bdad58ec5ffcb087300a17f7fef1f7c  # MD5  key
                         18 MDC2 a8d5e2315c025bf3a79174c87fbd10477de2eabc  # MDC2 key
                         19 RIPEMD160 77ca332cafb30e3cafb174dcd5b80ded7ba9b3d2  # RIPEMD160 key
                         20 AES128CMAC f92ff73eee86c1e7dc638d6489a04e4e555af878  # AES128CMAC key
             Figure 1. Typical Symmetric Key File

Figure 1 shows a typical symmetric keys file used by the reference implementation ๐ŸŒˆ. Following the header the keys are entered one per line in the format

keyno type key

where keyno is a positive integer in the range 1-65535; type is the key type for the message digest algorithm, which in the absence of the OpenSSL library must be MD5 to designate the MD5 message digest algorithm; if the OpenSSL library is installed, the key type can be any message digest algorithm supported by that library; however, if compatibility with FIPS 140-2 is required, the key type must be either SHA or SHA1 โญ; key is the key itself, which is a printable ASCII string 20 characters or less in length: each character is chosen from the 93 printable characters in the range 0x21 through 0x7e ( โ€˜!โ€™ through โ€˜~โ€™ ) excluding space and the โ€˜#โ€™ character, and terminated by whitespace or a โ€˜#โ€™ character. An OpenSSL key consists of a hex-encoded ASCII string of 40 characters, which is truncated as necessary.

Note that the keys used by the ntpq(1) and ntpdc(1) programs are checked against passwords requested by the programs and entered by hand, so it is generally appropriate to specify these keys in human readable ASCII format ๐Ÿ™ˆ.

The ntp-keygen program generates a symmetric keys file ntpkey_MD5key_hostname.filestamp ๐Ÿ’–. Since the file contains private shared keys, it should be visible only to root and distributed by secure means to other subnet hosts. The NTP daemon loads the file ntp.keys, so ntp-keygen installs a soft link from this name to the generated file ๐ŸŽ€. Subsequently, similar soft links must be installed by manual or automated means on the other subnet hosts. While this file is not used with the Autokey Version 2 protocol, it is needed to authenticate some remote configuration commands used by the ntpq(1) and ntpdc(1) utilities ๐Ÿ”ฅ.

โœจ OPTIONS โœจ

okay bestie, this is the whole menu ๐Ÿ“ every single flag, no skips, no "and the rest", we're doing ALL of them. grab a snack, we're going in ๐Ÿ’–

  • -b imbits, --imbits=imbits โ€” identity modulus bits. This one takes an integer number as its argument, and imbits is constrained to being in the range 256 through 2048. It's the number of bits in the identity modulus, and the default is 256.
  • -c scheme, --certificate=scheme โ€” certificate scheme. scheme is one of RSA-MD2, RSA-MD5, RSA-MDC2, RSA-SHA, RSA-SHA1, RSA-RIPEMD160, DSA-SHA, or DSA-SHA1. This selects the certificate signature encryption/message digest scheme. Important though ๐Ÿ‘€ โ€” RSA schemes must be used with a RSA sign key, and DSA schemes must be used with a DSA sign key, no mixing and matching. If you don't pass this option at all, the default is RSA-MD5.
  • -C cipher, --cipher=cipher โ€” privatekey cipher. Picks the cipher used to encrypt the files that hold private keys. Default is three-key triple DES in CBC mode, which is equivalent to -C des-ede3-cbc. The openssl tool lists the ciphers that are available in its openssl -h output.
  • -d, --debug-level โ€” increase debug verbosity level. This option may appear an unlimited number of times, so stack it up as much as you want ๐Ÿ“ˆ.
  • -D number, --set-debug-level=number โ€” set the debug verbosity level. May appear an unlimited number of times, and it takes an integer number as its argument.
  • -e, --id-key โ€” write IFF or GQ identity keys. Writes the public parameters from the IFF or GQ client keys to the standard output. This is intended for automatic key distribution by email. ๐Ÿ“ง
  • -G, --gq-params โ€” generate GQ parameters and keys. Generates parameters and keys for the GQ identification scheme, obsoleting any that may exist.
  • -H, --host-key โ€” generate RSA host key. Generates new host keys, obsoleting any that may exist.
  • -I, --iffkey โ€” generate IFF parameters. Generates parameters for the IFF identification scheme, obsoleting any that may exist.
  • -i group, --ident=group โ€” set Autokey group name. Sets the optional Autokey group name to name. This gets used in the file name of IFF, GQ, and MV client parameters files. In that role, the default is the host name if this option isn't provided. The group name โ€” whether you specify it using -i/--ident or using -s/--subject-name following an '@' character โ€” is also a part of the self-signed host certificate subject and issuer names in the form host@group, and it should match the 'crypto ident' or 'server ident' configuration in the ntpd configuration file.
  • -l lifetime, --lifetime=lifetime โ€” set certificate lifetime. Takes an integer number as its argument. Sets the certificate expiration to lifetime days from now. โณ
  • -m modulus, --modulus=modulus โ€” prime modulus. Takes an integer number as its argument, and modulus is constrained to being in the range 256 through 2048. It's the number of bits in the prime modulus, and the default is 512.
  • -M, --md5key โ€” generate symmetric keys. Generates symmetric keys, obsoleting any that may exist.
  • -P, --pvt-cert โ€” generate PC private certificate. Generates a private certificate. By default, the program generates public certificates.
  • -p passwd, --password=passwd โ€” local private password. Local files containing private data get encrypted with the DES-CBC algorithm and the password you specify. The same password must be specified to the local ntpd via the "crypto pw password" configuration command. The default password is the local hostname.
  • -q passwd, --export-passwd=passwd โ€” export IFF or GQ group keys with password. Exports IFF or GQ identity group keys to the standard output, encrypted with the DES-CBC algorithm and the password you specify. The same password must be specified to the remote ntpd via the "crypto pw password" configuration command. Also peep the --id-key (-e) option if you want unencrypted exports.
  • -s host@group, --subject-name=host@group โ€” set host and optionally group name. Sets the Autokey host name, and optionally a group name following an '@' character. The host name is used in the file name of generated host and signing certificates, without the group name. The host name, and if provided the group name, are used in host@group form for the host certificate subject and issuer fields. Specifying '-s @group' is allowed, and it results in leaving the host name unchanged while appending @group to the subject and issuer fields, just like with -i group. The group name โ€” or, if it's not provided, the host name โ€” is also used in the file names of IFF, GQ, and MV client parameter files.
  • -S sign, --sign-key=sign โ€” generate sign key (RSA or DSA). Generates a new sign key of the designated type, obsoleting any that may exist. By default, the program uses the host key as the sign key.
  • -T, --trusted-cert โ€” trusted certificate (TC scheme). Generates a trusted certificate. By default, the program generates a non-trusted certificate.
  • -V num, --mv-params=num โ€” generate <num> MV parameters. Takes an integer number as its argument. Generates parameters and keys for the Mu-Varadharajan (MV) identification scheme.
  • -v num, --mv-keys=num โ€” update <num> MV keys. Takes an integer number as its argument. Heads up bestie โ€” this option has not been fully documented ๐Ÿ™ˆ.
  • -?, --help โ€” Display usage information and exit.
  • -!, --more-help โ€” Pass the extended usage information through a pager.
  • -> [cfgfile], --save-opts [=cfgfile] โ€” Save the option state to cfgfile. The default is the last configuration file listed in the OPTION PRESETS section, below. The command will exit after updating the config file.
  • -< cfgfile, --load-opts=cfgfile, --no-load-opts โ€” Load options from cfgfile. The no-load-opts form will disable the loading of earlier config/rc/ini files. Note that --no-load-opts is handled early, out of order.
  • --version [{v|c|n}] โ€” Output version of program and exit. The default mode is 'v', a simple version. The 'c' mode will print copyright information and 'n' will print the full copyright notice.

๐ŸŒธ OPTION PRESETS ๐ŸŒธ

So here's the tea โ˜• โ€” any option that is not marked as not presettable can be preset by loading values from configuration ("RC" or ".INI") file(s), and values from environment variables named:

NTP_KEYGEN_<option-name> or NTP_KEYGEN

The environmental presets take precedence (they're processed later than) the configuration files. The homerc files are "$HOME", and ".". And if any of these are directories, then the file .ntprc is searched for within those directories. ๐Ÿซถ


๐Ÿฆ‹ USAGE ๐Ÿฆ‹

(no content here in the original, bestie โ€” it's just vibes and a heading ๐Ÿ’€)


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

See OPTION PRESETS for configuration environment variables.


๐ŸŽ€ FILES ๐ŸŽ€

See OPTION PRESETS for configuration files.


โœจ EXIT STATUS โœจ

One of the following exit values will be returned:

  • 0 (EXIT_SUCCESS) โ€” Successful program execution. ๐ŸŽ‰
  • 1 (EXIT_FAILURE) โ€” The operation failed or the command syntax was not valid.
  • 66 (EX_NOINPUT) โ€” A specified configuration file could not be loaded.
  • 70 (EX_SOFTWARE) โ€” libopts had an internal operational error. Please report it to autogen-users@lists.sourceforge.net. Thank you! ๐Ÿ’–

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

The University of Delaware and Network Time Foundation


Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved. This program is released under the terms of the NTP license, <http://ntp.org/license>.


๐Ÿ’€ BUGS ๐Ÿ’€

It can take quite a while to generate some cryptographic values. โณ be patient bestie, it's cooking.

Please report bugs to http://bugs.ntp.org .

Please send bug reports to: http://bugs.ntp.org, bugs@ntp.org


โญ NOTES โญ

Portions of this document came from FreeBSD.

This manual page was AutoGen-erated from the ntp-keygen option definitions. ๐Ÿค–


and that's the whole page, bestie!! we ate and left no crumbs ๐Ÿฝ๏ธ๐Ÿ’… this one shipped out of Debian on June 23 2020, and it's the NTP_KEYGEN(8) manual page. go forth and generate those keys, you absolute icon ๐ŸŒŸ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from