Verify host key in JSch with public key in “SSH2 PUBLIC KEY” format (RFC 4716)

时光总嘲笑我的痴心妄想 提交于 2019-12-23 02:29:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!