Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add password to keytool command

I've made a .bat file to get the SHA1 of my Android app so I don't need to type the command each time

keytool -list -v -keystore "Path/To/My/Key.jks"

When I run the bat file I get asked for the password. Is it possible to either put the password in the command e.g. something like --password MyPassword, or in the .bat file wait for the Enter your password line, and then send the password? I don't have any experience really with .bat files so I don't know if that's possible to do or not.

I looked at the --help for keytool and the only password flags I could see were for changing the password, not specifying it.

like image 388
TMH Avatar asked Feb 28 '14 11:02

TMH


People also ask

How do I find my Keytool password?

From the logs: If you have your logs intact, then you can find the password in the Android Studio log files : Go to ~/Library/Logs -> AndroidStudio ->idea. log.

What is the default Keytool password?

The default server password is changeit . The keytool application is included in the Java developer kit and is not part of IBM® UrbanCode Deploy.

What is keystore key password?

As already answered by @Maas, keyPassword is required to access the key entry that is stored in the KeyStore. The way it happens is first KeyStore Password is used to access/unlock the KeyStore and then keyPassword is used to decrypt the key entry that is there inside that KeyStore.


2 Answers

The keytool that ships with the Oracle JDK allows you to specify it on the command line with -storepass, you were doing keytool -help instead of keytool -list -help. (I suppose the Android version is the same.)

C:\>keytool.exe -list -help keytool -list [OPTION]...  Lists entries in a keystore  Options:   -rfc                            output in RFC style  -alias <alias>                  alias name of the entry to process  -keystore <keystore>            keystore name  -storepass <arg>                keystore password  -storetype <storetype>          keystore type  -providername <providername>    provider name  -providerclass <providerclass>  provider class name  -providerarg <arg>              provider argument  -providerpath <pathlist>        provider classpath  -v                              verbose output  -protected                      password through protected mechanism  Use "keytool -help" for all available commands 
like image 61
rxg Avatar answered Sep 20 '22 15:09

rxg


Specify the keystore password using the -storepass option:

keytool <commands and options> -storepass changeit 

changeit being the default keystore password, but use whatever.

For example, to add a certificate using the default password:

keytool -importcert -trustcacerts -alias mycert -file mycert.cer -keystore .../lib/security/cacerts -storepass changeit 
like image 29
Bohemian Avatar answered Sep 20 '22 15:09

Bohemian