Generate public and private keys.
ntp-keygen [ -d ] [ -e ] [ -G ] [ -g ] [ -H ] [ -I ] [ -M ] [ -P ] [ -T ] [-c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ -i name ] [ -m modulus ] [ -p password ] [ -q password ] [ -S [ RSA | DSA ] ] [ -s name ] [ -v nkeys ] [ -V params]
The ntp-keygen4 command generates cryptographic data files used by the NTP version 4 authentication and identification schemes. It generates MD5 key files used in symmetric key cryptography. In addition, if the OpenSSL software library has been installed, it generates keys, certificate and identity files used in public key cryptography. These files are used for cookie encryption, digital signature and challenge/response identification algorithms compatible with the Internet standard security infrastructure.
By default, files are not encrypted by ntp-keygen. The -p password option specifies the write password and -q password option the read password for previously encrypted files. The ntp-keygen program prompts for the password if it reads an encrypted file and the password is missing or incorrect. If an encrypted file is read successfully and no write password is specified, the read password is used as the write password by default.
The ntpd configuration command crypto pw password specifies the read password for previously encrypted files. The daemon expires on the spot if the password is missing or incorrect. For convenience, if a file has been previously encrypted, the default read password is the name of the host running the program. If the previous write password is specified as the host name, these files can be read by that host with no explicit password.
All files are in PEM-encoded printable ASCII format, so they can be embedded as MIME attachments in mail to other sites and certificate authorities. File names begin with the prefix ntpkey_ and end with the postfix _hostname.filestamp, where hostname is usually the string returned by the Unix gethostname() routine, and filestamp is the NTP seconds when the file was generated, in decimal digits. This both guarantees uniqueness and simplifies maintenance procedures, since all files can be quickly removed by a rm ntpkey* command or all files generated at a specific time can be removed by a rm *filestamp command. To further reduce the risk of misconfiguration, the first two lines of a file contain the file name and generation date and time as comments.
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 file name extensions, the files for a NFS server and dependent clients can all be installed in the same shared directory.
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 follows it to the file name to extract the filestamp. If a link is not present, ntpd 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 extension for all files generated at one time, so each generation is distinct and can be readily recognized in monitoring data.
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 /ust/local/etc, then run the program. When run for the first time, or if all ntpkey files have been removed, the program generates a RSA host key file and matching RSA-MD5 certificate file, which is all that is necessary in many cases. The program also generates soft links from the generic names to the respective files. If run again, the program uses the same host key file, but generates a new certificate file and link.
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 MD2, MD5, SHA, SHA1, MDC2 and RIPE160 message digest algorithms. However, 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.
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. 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 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.
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 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.
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.
Item | Description |
---|---|
-c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] | Selects certificate message digest/signature encryption scheme. Note that RSA schemes must be used with a RSA sign key and DSA schemes must be used with a DSA sign key. The default without this option is RSA-MD5. |
-d | Enables debugging. This option displays the cryptographic data produced in eye-friendly billboards. |
-e | Writes the IFF client keys to the standard output. This is intended for automatic key distribution by mail. |
-G | Generates parameters and keys for the GQ identification scheme, obsoleting any that may exist. |
-g | Generates keys for the GQ identification scheme using the existing GQ parameters. If the GQ parameters do not yet exist, create them first. |
-H | Generates new host keys, obsoleting any that may exist. |
-I | Generates parameters for the IFF identification scheme, obsoleting any that may exist. |
-i name | Sets the subject name to name. This is used as the subject field in certificates and in the file name for host and sign keys. |
-M | Generates MD5 keys, obsoleting any that may exist. |
-m modulus | Sets prime modulus size in bits (256 - 2048). Default size is 512. |
-P | Generates a private certificate. By default, the program generates public certificates. |
-p password | Encrypts generated files containing private data with password and the DES-CBC algorithm. |
-q password | Sets the password for reading files to password. |
-S [ RSA | 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. |
-s name | Sets the issuer name to name. This is used for the issuer field in certificates and in the file name for identity files. |
-T | Generates a trusted certificate. By default, the program generates a non-trusted certificate. |
-V nkeys | Generates parameters and keys for the Mu-Varadharajan (MV) identification scheme. |
This command returns the following exit values:
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
Access Control: You must be part of the system group to run this command.
Auditing Events: N/A
ntp-keygen -c RSA-SHA
ntpdc -p
Output similar to the following appears:
Using OpenSSL version 90804f
Generating RSA keys (512 bits)...
RSA 3 1 2
Generating new host file and link
ntpkey_host_aixfvt12->ntpkey_RSAkey_aixfvt12.3444540821
Using host key as sign key
Generating certificate RSA-SHA
X509v3 Basic Constraints: critical,CA:TRUE
X509v3 Key Usage: digitalSignature,keyCertSign
Generating new cert file and link
ntpkey_cert_aixfvt12->ntpkey_RSA-SHAcert_aixfvt12.3444540821
Item | Description |
---|---|
/usr/sbin/ntp4/ntp-keygen4 | Contains the ntp-keygen command. The default symbolic link to the NTP version 4 binary from /usr/sbin directory. /usr/sbin/ntp-keygen --> /usr/sbin/ntp4/ntp-keygen4 |