Class KnownHostEntryReader

  • public class KnownHostEntryReader
    extends Object
    Apache MINA sshd 2.0.0 KnownHostEntry cannot read a host entry line like "host:port ssh-rsa "; it complains about an illegal character in the host name (correct would be "[host]:port"). The default known_hosts reader also aborts reading on the first error.

    This reader is a bit more robust and tries to handle this case if there is only one colon (otherwise it might be an IPv6 address (without port)), and it skips and logs invalid entries, but still returns all other valid entries from the file.

    • Method Detail

      • readFromFile

        public static List<org.apache.sshd.client.config.hosts.KnownHostEntry> readFromFile​(Path path)
                                                                                     throws IOException
        Reads a known_hosts file and returns all valid entries. Invalid entries are skipped (and a message is logged).
        path - of the file to read
        a List of all valid entries read from the file
        IOException - if the file cannot be read.