There have seen a number of similar question,but none exactly like mine. The given answers have not worked for me. I wanted to add a private ssh key to a java keystore in command line and later retrive it in java code.
I have generated the ssh keys in the following way :
ssh-keygen -t rsa -b 4096 -C "abc@xyz.com"
That gives me 2 key file. 'id_rsa' and 'id_rsa.pub' i.e the public and private key
I want to store just the private key i.e. 'id_rsa' into the java keystore using the keytool command line tool.
I am trying something like this.
openssl pkcs12 -export -inkey key -in key.pub -out identity.p12 -name alias1 -nocerts
keytool -importkeystore -deststorepass "password1" -destkeypass "password2" -destkeystore ~/jks/keystore1.jks -srckeystore /tmp/keys/identity.p12 -srcstoretype PKCS12 -srcstorepass "pass" -alias "alias1"
But that gives me 'keytool error: java.lang.NullPointerException: invalid null input'
Please guide me on the best way to achieve this.