We need to better support known_hosts formats in KiwiJschHelpers etc. #577
Closed
sleberknight
started this conversation in
Ideas
Replies: 1 comment
-
The few services we had that were still using SFTP for anything have now been decommissioned, so this is no longer needed. However, we probably should document this limitation in the existing |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
Currently
KiwiJSchHelpers
has a private nested classKnownHost
that can only handle the followinghostname
e.gdev-svc-1.acme.com
ip_address
e.g.192.168.1.150
hostname,ip_address
e.g.dev-svc-1.acme.com,192.168.1.150
However,
known_hosts
can have various other formats. For example:[ssh.example.org]:2222 ssh-rsa AAAAB3Nz...AKy2R2OE=
[127.0.0.2]:4922 ssh-rsa AAAAB4mV...1d6j=
[anga.funkfeuer.at]:2022,[78.41.115.130]:2022 ssh-rsa AAAAB...fgTHaojQ==
And it can also have salted + hashed versions of the host name and IP address, e.g.
|1|F1E1KeoE/eEWhi10WpGv4OdiO6Y=|3988QV0VE8wmZL7suNrYQLITLCg= ssh-rsa ...
The only code I found dealing with the hashed hostnames is KnownHosts.java by Christian Plattner. It came from Ganymed SSH-2 for Java which is no longer maintained. It points you to an old google code site that returns a 404, so just search for "ganymed-ssh-2". You'll find a bunch of forks on GitHub. The fork from SoftwareAG here seems to be one of the most recent ones. It's too bad this stuff isn't part of the standard JDK libraries...
Goals
We should be able to handle all these various
known_hosts
formats in our SFTP utilities.KiwiJSchHelpers
which is in theorg.kiwiproject.jsch
package)ganymed-ssh-2
Misc
And also, during all this searching, I came across Automatically Accept SSH Fingerprint which talks about the
ssh-keyscan
tool which lets you find the public keys of remote servers.We could also consider providing a way to automatically add public keys to remote hosts, assuming we put the same caveats regarding security on whatever code comes out of it...
References
Some of the things I came across while doing this research, in no particular order:
Beta Was this translation helpful? Give feedback.
All reactions