keytool error bash: keytool: command not found

Solution 1:

These are the steps which solved my problem:

  • Search the path where my java was installed

    find / -name jre
    
  • Move to java directory (where jre was installed on my server)

    cd /path/to/jre/bin
    
  • Create SSL certificate with keytool command

    ./keytool -genkey -alias [mypassword] -keyalg [RSA]
    

Solution 2:

Use

./keytool -genkey -alias mypassword -keyalg RSA

Solution 3:

Ensure jre is installed.

cd /path/to/jre/bin/folder

As keytool file is present in the bin folder of jre, give path till bin as in the command above.

Then you can do:

keytool -genkey -alias aliaskeyname -keyalg RSA -keystore C:\mykeystore

The additional option -keystore will help you to specify the path where you want the generated self signed certificate.

Solution 4:

find your jre location ::sudo find / -name jre And then :: sudo update-alternatives --install /usr/bin/keytool keytool /opt/jdk/<jdk.verson>/jre/bin/keytool 100

Solution 5:

If you are looking for keytool because you are working with Android studio / Google Firebase, there is a keytool bundled with Android Studio. After extracting the zip file, the path to keytool is android-studio/jre/bin.