Class SshKeyScanMain
java.lang.Object
org.apache.sshd.cli.client.SshKeyScanMain
- All Implemented Interfaces:
Closeable, AutoCloseable, Channel, Callable<Void>, EventListener, org.apache.sshd.client.keyverifier.ServerKeyVerifier, org.apache.sshd.common.session.SessionListener, org.apache.sshd.common.util.logging.SimplifiedLog, org.apache.sshd.common.util.SshdEventListener
public class SshKeyScanMain
extends Object
implements Channel, Callable<Void>, org.apache.sshd.client.keyverifier.ServerKeyVerifier, org.apache.sshd.common.session.SessionListener, org.apache.sshd.common.util.logging.SimplifiedLog
A naive implementation of
ssh-keyscan(1)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionListener
org.apache.sshd.common.session.SessionListener.Event -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.apache.sshd.client.SshClientDefault key types if not overridden from the command linestatic final Levelstatic final longprivate InputStreamprivate Levelprivate final AtomicBooleanprivate intprivate longFields inherited from interface org.apache.sshd.common.util.logging.SimplifiedLog
EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()voidclose()createKeyPairs(String keyType) createKeyPairs(Collection<String> typeNames) intgetPort()longstatic <S extends SshKeyScanMain>
SinitializeScanner(S scanner, Collection<String> hosts) booleanisEnabledLevel(Level level) booleanisOpen()voidprotected voidlogNegotiationProposal(String type, Map<org.apache.sshd.common.kex.KexProposalOption, String> proposal) protected voidlogSessionEvent(org.apache.sshd.common.session.Session session, Object event) static voidparseCommandLineArguments(SshKeyScanMain scanner, String... args) ///////////////////////////////////////////////////////////////////////protected voidresolveServerKeys(org.apache.sshd.client.SshClient client, String host, String kt, List<KeyPair> ids) protected voidresolveServerKeys(org.apache.sshd.client.SshClient client, String host, Map<String, List<KeyPair>> pairsMap, Map<String, List<org.apache.sshd.common.NamedFactory<org.apache.sshd.common.signature.Signature>>> sigFactories) protected List<org.apache.sshd.common.NamedFactory<org.apache.sshd.common.signature.Signature>> resolveSignatureFactories(String keyType) voidsessionClosed(org.apache.sshd.common.session.Session session) voidsessionCreated(org.apache.sshd.common.session.Session session) voidsessionEvent(org.apache.sshd.common.session.Session session, org.apache.sshd.common.session.SessionListener.Event event) voidsessionException(org.apache.sshd.common.session.Session session, Throwable t) voidsessionNegotiationEnd(org.apache.sshd.common.session.Session session, Map<org.apache.sshd.common.kex.KexProposalOption, String> clientProposal, Map<org.apache.sshd.common.kex.KexProposalOption, String> serverProposal, Map<org.apache.sshd.common.kex.KexProposalOption, String> negotiatedOptions, Throwable reason) voidsessionNegotiationStart(org.apache.sshd.common.session.Session session, Map<org.apache.sshd.common.kex.KexProposalOption, String> clientProposal, Map<org.apache.sshd.common.kex.KexProposalOption, String> serverProposal) voidsetInputStream(InputStream input) static <S extends SshKeyScanMain>
SsetInputStream(S scanner, Collection<String> hosts) voidsetKeyTypes(List<String> keyTypes) voidsetLogLevel(Level level) voidsetPort(int port) voidsetTimeout(long timeout) private static StringtoString(SocketAddress addr) booleanverifyServerKey(org.apache.sshd.client.session.ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) protected voidwriteServerKey(String remoteLocation, String keyType, PublicKey serverKey) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.sshd.common.session.SessionListener
sessionDisconnect, sessionEstablished, sessionNegotiationOptionsCreated, sessionPeerIdentificationLine, sessionPeerIdentificationReceived, sessionPeerIdentificationSendMethods inherited from interface org.apache.sshd.common.util.logging.SimplifiedLog
debug, debug, error, error, info, info, isDebugEnabled, isErrorEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabled, log, trace, trace, warn, warn
-
Field Details
-
DEFAULT_KEY_TYPES
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT -
DEFAULT_LEVEL
-
open
-
client
private org.apache.sshd.client.SshClient client -
port
private int port -
timeout
private long timeout -
keyTypes
-
input
-
level
-
currentHostFingerprints
-
-
Constructor Details
-
SshKeyScanMain
public SshKeyScanMain()
-
-
Method Details
-
getPort
public int getPort() -
setPort
public void setPort(int port) -
getInputStream
-
setInputStream
-
getKeyTypes
-
setKeyTypes
-
getTimeout
public long getTimeout() -
setTimeout
public void setTimeout(long timeout) -
getLogLevel
-
setLogLevel
-
log
-
isEnabledLevel
- Specified by:
isEnabledLevelin interfaceorg.apache.sshd.common.util.logging.SimplifiedLog
-
call
-
resolveServerKeys
protected void resolveServerKeys(org.apache.sshd.client.SshClient client, String host, Map<String, List<KeyPair>> pairsMap, Map<String, List<org.apache.sshd.common.NamedFactory<org.apache.sshd.common.signature.Signature>>> sigFactories) throws IOException - Throws:
IOException
-
resolveServerKeys
-
sessionCreated
public void sessionCreated(org.apache.sshd.common.session.Session session) - Specified by:
sessionCreatedin interfaceorg.apache.sshd.common.session.SessionListener
-
sessionEvent
public void sessionEvent(org.apache.sshd.common.session.Session session, org.apache.sshd.common.session.SessionListener.Event event) - Specified by:
sessionEventin interfaceorg.apache.sshd.common.session.SessionListener
-
sessionException
- Specified by:
sessionExceptionin interfaceorg.apache.sshd.common.session.SessionListener
-
sessionClosed
public void sessionClosed(org.apache.sshd.common.session.Session session) - Specified by:
sessionClosedin interfaceorg.apache.sshd.common.session.SessionListener
-
sessionNegotiationStart
public void sessionNegotiationStart(org.apache.sshd.common.session.Session session, Map<org.apache.sshd.common.kex.KexProposalOption, String> clientProposal, Map<org.apache.sshd.common.kex.KexProposalOption, String> serverProposal) - Specified by:
sessionNegotiationStartin interfaceorg.apache.sshd.common.session.SessionListener
-
logNegotiationProposal
-
sessionNegotiationEnd
public void sessionNegotiationEnd(org.apache.sshd.common.session.Session session, Map<org.apache.sshd.common.kex.KexProposalOption, String> clientProposal, Map<org.apache.sshd.common.kex.KexProposalOption, String> serverProposal, Map<org.apache.sshd.common.kex.KexProposalOption, String> negotiatedOptions, Throwable reason) - Specified by:
sessionNegotiationEndin interfaceorg.apache.sshd.common.session.SessionListener
-
logSessionEvent
-
verifyServerKey
public boolean verifyServerKey(org.apache.sshd.client.session.ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) - Specified by:
verifyServerKeyin interfaceorg.apache.sshd.client.keyverifier.ServerKeyVerifier
-
writeServerKey
-
toString
-
resolveSignatureFactories
protected List<org.apache.sshd.common.NamedFactory<org.apache.sshd.common.signature.Signature>> resolveSignatureFactories(String keyType) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
createKeyPairs
protected Map<String, List<KeyPair>> createKeyPairs(Collection<String> typeNames) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
createKeyPairs
- Throws:
GeneralSecurityException
-
isOpen
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
parseCommandLineArguments
public static List<String> parseCommandLineArguments(SshKeyScanMain scanner, String... args) throws IOException ///////////////////////////////////////////////////////////////////////- Throws:
IOException
-
setInputStream
public static <S extends SshKeyScanMain> S setInputStream(S scanner, Collection<String> hosts) throws IOException - Throws:
IOException
-
initializeScanner
public static <S extends SshKeyScanMain> S initializeScanner(S scanner, Collection<String> hosts) throws IOException - Throws:
IOException
-
main
-