A robust, production-ready Bash script to automate the secure generation of Android App Signing Keystores using Java's keytool utility. This script complies with modern Android security standards, including the PKCS12 keystore format, matching store/key passwords, and Google Play's 25+ year validity recommendation.
- Modern Standards: Generates standard standard-compliant PKCS12 format keystores.
- Identical Passwords: Uses a single password for both the store and the key to prevent PKCS12 keytool issues.
- Extended Validity: Sets key validity to 20,000 days (approximately 54 years), meeting and exceeding Google Play's minimum 25-year mandate.
- Descriptive CLI Flags: Uses expressive, self-documenting command-line arguments instead of cryptic single-letter options.
- Save the generator script to your local system as
generate_keystore.sh. - Give the file executable permissions in your terminal:
chmod +x generate_keystore.sh
You must provide a password using the --password flag. All other fields have sensible default values but should be configured for production releases.
./generate_keystore.sh \
--keystore-name "production-app.keystore" \
--key-alias "production-alias" \
--password "YourSecurePassword123" \
--common-name "Sarah Dev" \
--org-unit "Mobile Department" \
--organization "My Tech Company" \
--locality "Kampala" \
--state "Central" \
--country "UG"To see all available CLI options and default values:
./generate_keystore.sh --help| Option | Description | Default Value | Required |
|---|---|---|---|
--password <value> |
Secure password used for both keystore and key integrity | None | Yes |
--keystore-name <value> |
Destination file path for the generated keystore | my-release-key.keystore |
No |
--key-alias <value> |
Internal alias name for the private key | my-key-alias |
No |
--common-name <value> |
Developer or Organization representative name | Unknown |
No |
--org-unit <value> |
Business unit, department, or team designation | Dev |
No |
--organization <value> |
Company name | Company |
No |
--locality <value> |
City or municipality | City |
No |
--state <value> |
State, province, or region | State |
No |
--country <value> |
Two-letter ISO country code | US |
No |
Modern Android development workflows utilize the generated keystore file as an Upload Key.
- Google Play Console Mandate: For new applications, Google Play manages your primary App Signing Key on secure Google infrastructure.
- Your Responsibility: You will sign your local Android App Bundle (
.aab) with the keystore generated by this script before uploading it to the Play Console. - Recovery: If you lose this upload key, you can reset it via the Play Console Developer support channel.