问题
I am facing a problem with UnknownHostKey: servername
, when trying to verify the host key using:
jsch.setKnownHosts("target/hostname_keys");
Is it possible to use hostkey file in SSH2 format that looks like this
---- BEGIN SSH2 PUBLIC KEY ----
AAAAB3NzaC1kc3MAAACBAKKQ7hwq7
.....
w5Uw==
---- END SSH2 PUBLIC KEY ----
with JSch?
Is there some good libraries that can work with SSH2 keys?
回答1:
JSch does not support public keys in this format.
But it's easy to convert that to known_hosts
format.
Basically, just merge the lines into one and prepend a hostname:
example.com AAAAB3NzaC1kc3MAAACBAKKQ7hwq7...w5Uw==
来源:https://stackoverflow.com/questions/55734483/verify-host-key-in-jsch-with-public-key-in-ssh2-public-key-format-rfc-4716