Class OpenSSHKnownHosts

    • Field Detail

      • log

        protected final org.slf4j.Logger log
      • khFile

        protected final java.io.File khFile
    • Constructor Detail

      • OpenSSHKnownHosts

        public OpenSSHKnownHosts​(java.io.Reader reader)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • OpenSSHKnownHosts

        public OpenSSHKnownHosts​(java.io.File khFile)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • OpenSSHKnownHosts

        public OpenSSHKnownHosts​(java.io.File khFile,
                                 LoggerFactory loggerFactory)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • OpenSSHKnownHosts

        public OpenSSHKnownHosts​(java.io.Reader reader,
                                 LoggerFactory loggerFactory)
                          throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getFile

        public java.io.File getFile()
      • verify

        public boolean verify​(java.lang.String hostname,
                              int port,
                              java.security.PublicKey key)
        Description copied from interface: HostKeyVerifier
        This callback is invoked when the server's host key needs to be verified. The return value indicates to the caller whether the SSH connection should proceed.

        Note: host key verification is the basis for security in SSH, therefore exercise due caution in implementing!

        Specified by:
        verify in interface HostKeyVerifier
        Parameters:
        hostname - remote hostname
        port - remote port
        key - host key of server
        Returns:
        true if key is acceptable, false otherwise
      • findExistingAlgorithms

        public java.util.List<java.lang.String> findExistingAlgorithms​(java.lang.String hostname,
                                                                       int port)
        Description copied from interface: HostKeyVerifier
        It is necessary to connect with the type of algorithm that matches an existing know_host entry. This will allow a match when we later verify with the negotiated key HostKeyVerifier.verify
        Specified by:
        findExistingAlgorithms in interface HostKeyVerifier
        Parameters:
        hostname - remote hostname
        port - remote port
        Returns:
        existing key types or empty list if no keys known for hostname
      • hostKeyUnverifiableAction

        protected boolean hostKeyUnverifiableAction​(java.lang.String hostname,
                                                    java.security.PublicKey key)
      • hostKeyChangedAction

        protected boolean hostKeyChangedAction​(java.lang.String hostname,
                                               java.security.PublicKey key)
      • write

        public void write()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • detectSSHDir

        public static java.io.File detectSSHDir()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object