How to change the alias of a key within a keystore? How to change the alias of a key within a keystore? java java

How to change the alias of a key within a keystore?


It is possible to duplicate a key in a keystore with the keyclone command of keytool:

keytool -keyclone -alias "your-very-very-long-alias" -dest "new-alias" -keypass keypass -new new_keypass -keystore /path/to/keystore -storepass storepass

The changealias command changes the alias for an existing entry:

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keypass keypass -keystore /path/to/keystore -storepass storepass

For those that want to be prompted to enter password just remove the respective password flags (changealias example):

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keystore "/path/to/keystore"