Below is a complete command that generates a public/private key
pair and specifies all the required entity information without asking
you any questions about your identity; that information is provided
directly on the command line. The table that follows explains each
option in the command.
keytool -genkey -alias clientprivate -keystore client.private
-storetype JKS -keyalg rsa -dname "CN=Your Name, OU=Your
Organizational Unit, O=Your Organization, L=Your City, S=Your State,
C=Your Country" -storepass clientpw -keypass clientpw
Option | What it means |
---|
-genkey | Tells keytool to generate a key pair. |
-alias clientprivate | Identifies the new key pair within the keystore. |
-keystore client.private | Uses the file client.private as the keystore. |
-storetype JKS | Declares the type of the keystore. JKS is the default. |
-keyalg rsa | Declares the algorithm to be used; we're using the RSA public key algorithm, which is the default. |
-dname "CN=Your Name..." | Provides information about the entity owning the key pair. |
-storepass clientpw | Specifies the password for the entire keystore. |
-keypass clientpw | Specifies the password for the new key pair. |