316

I currently have a keystore, with a particular password that only I should know. I now need to give access to that keystore to someone else, so I would like to either:

1) Change the password, so I can share it with others and let them sign
2) Create a different password and allow them to sign with it.

Is this possible? and - if yes - how?

8 Answers 8

570

Keystore only has one password. You can change it using keytool:

keytool -storepasswd -keystore my.keystore

To change the key's password:

keytool -keypasswd  -alias <key_name> -keystore my.keystore
10
  • 7
    Great, so the signature of the apk will be the same? Just the password will change? This is what I need too. Chose a bad password, now need to change it. Nov 15, 2011 at 7:50
  • 7
    Signature won't change, as app is NOT signed with the keystore, but with certificate you keep in keystore. Jan 16, 2013 at 19:46
  • keyName is the name of the alias, eg. -alias Dipu
    – ılǝ
    Apr 2, 2014 at 7:50
  • 31
    To remove the password for key, one has to set the same password as for keystore, may be useful for someone ;-)
    – Betlista
    Jun 10, 2015 at 11:43
  • 3
    Found this tool which has a more visual view of of the jks files keystore-explorer.org/index.html
    – Bogdan
    Dec 14, 2017 at 15:03
97

[How can I] Change the password, so I can share it with others and let them sign

Using keytool:

keytool -storepasswd -keystore /path/to/keystore
Enter keystore password:  changeit
New keystore password:  new-password
Re-enter new keystore password:  new-password
6
  • does this change the password for the key inside too? Jul 6, 2012 at 15:47
  • 5
    No. Keystore is one things, passwords (note plural) is another. Use keytool -keypasswd -alias <KeyName> -keystore my.keystore to change password of private key <KeyName> Jan 16, 2013 at 19:45
  • 7
    after enter keystore pass -changeit it gives error keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect
    – Dilip
    Nov 25, 2013 at 10:25
  • @Dipu, I am getting same error. Have you managed to resolved that
    – JiteshW
    Feb 7, 2016 at 11:14
  • You can verify that the password has changed (if you have doubt) by running the exact same command again. After it prompts for the existing password, if you enter a password that is incorrect, it'll say you entered the wrong password or the file has been tampered with and abort. Apr 7, 2016 at 13:55
54

Changing keystore password

$ keytool -storepasswd -keystore keystorename
Enter keystore password:  <old password>
New keystore password: <new password>
Re-enter new keystore password: <new password>

Changing keystore alias password

$ keytool -keypasswd -keystore keystorename -alias aliasname
Enter keystore password:  
New key password for <aliasname>: 
Re-enter new key password for <aliasname>:

Note:

  • keystorenam: name of your keystore (with path if you are in different folder)
  • aliasname: alias name you used when creating (if name has space you can use \)

For example:

$ keytool -keypasswd -keystore keystorename -alias stop\ watch
5
  • 1
    It works thank you! One more thing I want to add to change alias name which I wanted and got from a forum. keytool -changealias -keystore my.keystore -alias my_name -destalias my_new_name Sep 20, 2014 at 5:03
  • While changing the alias password I get: UnrecoverableKeyException: Cannot recover key Any suggestions?
    – Foo
    Jun 21, 2015 at 12:54
  • @Foo did you ever figure out that issue? I'm getting the same error May 9, 2016 at 23:04
  • 3
    Changing keystore alias password what ever you shown doesn't work, It won't ask New key password for <aliasname>. It asks existing password for <aliasname> which is not known in this case. Nov 11, 2016 at 19:29
  • I still get Cannot recover key at the step: New key password for <aliasname>: Any ideas? I just created the key in Android Studio, uploaded, realized I had to update something and now it doesnt work :/
    – Dewald Els
    Nov 8, 2017 at 8:47
23

To change the password for a key myalias inside of the keystore mykeyfile:

keytool -keystore mykeyfile -keypasswd -alias myalias
2
  • What is "inside key"? Oct 26, 2013 at 2:44
  • 5
    Sorry for my bad explanation. You can change the password of the keystore or the password of one of the keys you have stored on the keystore. That's what I mean with "inside key".
    – OriolJ
    Oct 29, 2013 at 9:50
11

For a full programmatic change (e.g. install program) and no prompting

#!/bin/bash -eu

NEWPASSWORD=${1}
OLDPASSWORD=${2}

keytool -storepasswd -new "${NEWPASSWORD}" \
  -storepass "${OLDPASSWORD}" \
  -keystore /path/to/keystore

Full disclosure: I DO NOT recommend running this command line in a shell, as the old and new passwords will be saved in the shell's history, and visible in console.

10

KeyStore Explorer is an open source GUI replacement for the Java command-line utilities keytool and jarsigner. KeyStore Explorer presents their functionality, and more, via an intuitive graphical user interface.

  1. Open an existing KeyStore
  2. Tools -> Set KeyStore password
2
  • best solution! Better than writing to the terminal. Using this software - I was able to change the passwords and add new key pairs. Highly recommend Feb 29, 2020 at 11:36
  • Fantastic little app, worked like a charm!
    – Leon
    Jan 27, 2022 at 10:49
8

If the keystore contains other key-entries with different password you have to change them also or you can isolate your key to different keystore using below command,

keytool -importkeystore  -srckeystore mystore.jck -destkeystore myotherstore.jks -srcstoretype jceks
-deststoretype jks -srcstorepass mystorepass -deststorepass myotherstorepass -srcalias myserverkey
-destalias myotherserverkey -srckeypass mykeypass -destkeypass myotherkeypass
0
6

There are so many answers here, but if you're trying to change the jks password on a Mac in Android Studio. Here are the easiest steps I could find

1) Open Terminal and cd to where your .jks is located

2) keytool -storepasswd -new NEWPASSWORD -keystore YOURKEYSTORE.jks

3) enter your current password

Not the answer you're looking for? Browse other questions tagged or ask your own question.