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
.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on September 01, 2020Comments
-
Admin almost 4 years
I have tried to execute keytool from Java bin directory but I get an error with warning bash: keytool: command not found.
root@xxxxxx]# keytool -genkey -alias mypassword -keyalg RSA bash: keytools: command not found
-
qualebs about 7 years@user217929 how can we solve this problem by adding
keytool
to$PATH
so that the command can be executed from any directory? -
Daniel Gray almost 7 yearsAdd
export PATH=$PATH:/path/to/jre/bin
to your.bashrc
file. -
deva11 over 6 yearsWhere will be the generated file location?
-
Allie over 4 yearsnote that the keytool is not in the jre folder, but in the bin folder
-
Moksh over 2 yearsPeople who are facing this issue inside docker image( I faced it in logstash 7.16.1), can use RUN cd ../.. && find / -iname keytool to find the correct path of it and change it in Dockerfile. Also, these debugging steps will be applicable to cacert file.
-
madebydavid about 2 years
alias keytool=$JAVA_HOME/bin/keytool