Class SshKeyScanMain

    • Field Detail

      • DEFAULT_KEY_TYPES

        public static final java.util.List<java.lang.String> DEFAULT_KEY_TYPES
        Default key types if not overridden from the command line
      • DEFAULT_TIMEOUT

        public static final long DEFAULT_TIMEOUT
      • DEFAULT_LEVEL

        public static final java.util.logging.Level DEFAULT_LEVEL
      • open

        private final java.util.concurrent.atomic.AtomicBoolean open
      • port

        private int port
      • timeout

        private long timeout
      • keyTypes

        private java.util.List<java.lang.String> keyTypes
      • input

        private java.io.InputStream input
      • level

        private java.util.logging.Level level
      • currentHostFingerprints

        private final java.util.Map<java.lang.String,​java.lang.String> currentHostFingerprints
    • Constructor Detail

      • SshKeyScanMain

        public SshKeyScanMain()
    • Method Detail

      • getPort

        public int getPort()
      • setPort

        public void setPort​(int port)
      • getInputStream

        public java.io.InputStream getInputStream()
      • setInputStream

        public void setInputStream​(java.io.InputStream input)
      • getKeyTypes

        public java.util.List<java.lang.String> getKeyTypes()
      • setKeyTypes

        public void setKeyTypes​(java.util.List<java.lang.String> keyTypes)
      • getTimeout

        public long getTimeout()
      • setTimeout

        public void setTimeout​(long timeout)
      • getLogLevel

        public java.util.logging.Level getLogLevel()
      • setLogLevel

        public void setLogLevel​(java.util.logging.Level level)
      • log

        public void log​(java.util.logging.Level level,
                        java.lang.Object message,
                        java.lang.Throwable t)
        Specified by:
        log in interface SimplifiedLog
      • isEnabledLevel

        public boolean isEnabledLevel​(java.util.logging.Level level)
        Specified by:
        isEnabledLevel in interface SimplifiedLog
      • call

        public java.lang.Void call()
                            throws java.lang.Exception
        Specified by:
        call in interface java.util.concurrent.Callable<java.lang.Void>
        Throws:
        java.lang.Exception
      • resolveServerKeys

        protected void resolveServerKeys​(SshClient client,
                                         java.lang.String host,
                                         java.util.Map<java.lang.String,​java.util.List<java.security.KeyPair>> pairsMap,
                                         java.util.Map<java.lang.String,​java.util.List<NamedFactory<Signature>>> sigFactories)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • resolveServerKeys

        protected void resolveServerKeys​(SshClient client,
                                         java.lang.String host,
                                         java.lang.String kt,
                                         java.util.List<java.security.KeyPair> ids)
                                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sessionException

        public void sessionException​(Session session,
                                     java.lang.Throwable t)
        Description copied from interface: SessionListener
        An exception was caught and the session will be closed (if not already so). Note: the code makes no guarantee that at this stage SessionListener.sessionClosed(Session) will be called or perhaps has already been called
        Specified by:
        sessionException in interface SessionListener
        Parameters:
        session - The referenced Session
        t - The caught exception
      • sessionNegotiationStart

        public void sessionNegotiationStart​(Session session,
                                            java.util.Map<KexProposalOption,​java.lang.String> clientProposal,
                                            java.util.Map<KexProposalOption,​java.lang.String> serverProposal)
        Description copied from interface: SessionListener
        Signals the start of the negotiation options handling
        Specified by:
        sessionNegotiationStart in interface SessionListener
        Parameters:
        session - The referenced Session
        clientProposal - The client proposal options (un-modifiable)
        serverProposal - The server proposal options (un-modifiable)
      • logNegotiationProposal

        protected void logNegotiationProposal​(java.lang.String type,
                                              java.util.Map<KexProposalOption,​java.lang.String> proposal)
      • sessionNegotiationEnd

        public void sessionNegotiationEnd​(Session session,
                                          java.util.Map<KexProposalOption,​java.lang.String> clientProposal,
                                          java.util.Map<KexProposalOption,​java.lang.String> serverProposal,
                                          java.util.Map<KexProposalOption,​java.lang.String> negotiatedOptions,
                                          java.lang.Throwable reason)
        Description copied from interface: SessionListener
        Signals the end of the negotiation options handling
        Specified by:
        sessionNegotiationEnd in interface SessionListener
        Parameters:
        session - The referenced Session
        clientProposal - The client proposal options (un-modifiable)
        serverProposal - The server proposal options (un-modifiable)
        negotiatedOptions - The successfully negotiated options so far - even if exception occurred (un-modifiable)
        reason - Negotiation end reason - null if successful
      • logSessionEvent

        protected void logSessionEvent​(Session session,
                                       java.lang.Object event)
      • verifyServerKey

        public boolean verifyServerKey​(ClientSession sshClientSession,
                                       java.net.SocketAddress remoteAddress,
                                       java.security.PublicKey serverKey)
        Description copied from interface: ServerKeyVerifier
        Verify that the server key provided is really the one of the host.
        Specified by:
        verifyServerKey in interface ServerKeyVerifier
        Parameters:
        sshClientSession - the current ClientSession
        remoteAddress - the host's SocketAddress
        serverKey - the presented server PublicKey
        Returns:
        true if the key is accepted for the host
      • writeServerKey

        protected void writeServerKey​(java.lang.String remoteLocation,
                                      java.lang.String keyType,
                                      java.security.PublicKey serverKey)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • toString

        private static java.lang.String toString​(java.net.SocketAddress addr)
      • resolveSignatureFactories

        protected java.util.List<NamedFactory<Signature>> resolveSignatureFactories​(java.lang.String keyType)
                                                                             throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • createKeyPairs

        protected java.util.Map<java.lang.String,​java.util.List<java.security.KeyPair>> createKeyPairs​(java.util.Collection<java.lang.String> typeNames)
                                                                                                      throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • createKeyPairs

        protected java.util.List<java.security.KeyPair> createKeyPairs​(java.lang.String keyType)
                                                                throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • parseCommandLineArguments

        public static java.util.List<java.lang.String> parseCommandLineArguments​(SshKeyScanMain scanner,
                                                                                 java.lang.String... args)
                                                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • setInputStream

        public static <S extends SshKeyScanMain> S setInputStream​(S scanner,
                                                                  java.util.Collection<java.lang.String> hosts)
                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • initializeScanner

        public static <S extends SshKeyScanMain> S initializeScanner​(S scanner,
                                                                     java.util.Collection<java.lang.String> hosts)
                                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception