Issue
Can I get the type (RSA
, DSA
, ECDSA
, ED25519
...) or the fingerprint of a passphrase protected private ssh key without unlocking it with JSch (like you can in Linux with ssh-keygen -l -f <key_file>
)?
I'm writing an Android app and JSch is pretty much the only lib that I managed to get to work with Android so it has to be done with JSch or manually.
Solution
Use KeyPair.load
to load the key.
And then KeyPair.getKeyType
and KeyPair.getFingerPrint
to access its properties.
JSch jSch = new JSch();
KeyPair keypair = KeyPair.load(jSch, filename);
System.out.println(keypair.getKeyType());
System.out.println(keypair.getFingerPrint(jSch));
Answered By - Martin Prikryl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.