We are connecting via ssh to a remote host from java with the sshj library. To do so we have configured a single fingerprint that is used during host verification.
After some time we started to get random host key verification errors. Out of multiple ssh connections, only some fails with
Disconnecting because none of the configured Host key verifiers ([net.schmizz.sshj.transport.verification.FingerprintVerifier$1@1696cbbf]) could verify 'ssh-ed25519' host key with fingerprint ... for ...
As far as I understand this is because the host has multiple keys configured for different algorithms (ssh-rsa
, ssh-ed25519
, ecdsa-sha2-nistp256
).
- What is the correct approach here, should we add multiple verifiers, one for each known key?
- Why is it random? What method is used by ssh/sshj to select the key being used?