Is there a way to make keytool not prompt for password for the key?

Dikshant Adhikari picture Dikshant Adhikari · Jan 18, 2018 · Viewed 7k times · Source

I am trying to generate a keystore. I have set a password for the keystore but I am trying to not set a password for the key.

keytool -storepass "$password" -keystore ${PFX_broker}server.keystore.jks -alias $brokerCertAlias -validity $validity -genkey -dname "CN=$CN" -noprompt;

The above command will prompt me for a key password which defaults to the store pass when I press enter.

Is it possible to skip setting a password for the key altogether and not have a prompt?

Answer

Alex picture Alex · May 5, 2019

There are parameters to specify key and store passwords

-keypass <your-pass> and -storepass <your-pass>

E.g.

keytool -storepass pass123 -keypass pass123 -keystore keystore.jks -alias myalias -validity 99 -genkey -noprompt

keytool reference