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 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] keytool to $PATH so that the command can be executed from any directory?export PATH=$PATH:/path/to/jre/bin to your .bashrc file.alias keytool=$JAVA_HOME/bin/keytoolUse
./keytool -genkey -alias mypassword -keyalg RSA This worked for me
sudo apt install openjdk-8-jre-headless 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.
If you are not using openjdk, use the below commands to set your keytool.
sudo update-alternatives --install "/usr/bin/keytool" "keytool" "/usr/lib/jvm/java8/jdk1.8.0_251/bin/keytool" 1 AND
sudo update-alternatives --set keytool /usr/lib/jvm/java8/jdk1.8.0_251/bin/keytool This worked for me!
You could also put this on one line like so:
/path/to/jre/bin/keytool -genkey -alias [mypassword] -keyalg [RSA]
Wanted to include this as a comment on piet.t answer but I don't have enough rep to comment.
See the "signing" section of this article that describes how to access the keytool.exe without changing your working directory to the path: https://flutter.dev/docs/deployment/android#signing-the-app
Note that they say you can type in space separated folder names like /"Program Files"/ with quotes but I found in bash i had to separate with back slashes like /Program\ Files/.
If the jre is installed on your machine properly then look for keytool in jre or in jre/bin
to find where jre is installed, use this
sudo find / -name jre
Then look for keytool in path_to_jre or in path_to_jre/bin
cd to keytool location
then run ./keytool
Make sure to add the the path to $PATH by
export PATH=$PATH:location_to_keytool
To make sure you got it right after this, run
where keytool
for future edit you bash or zshrc file and source it