Package org.apache.sshd.cli.client
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.SshClient
Default key types if not overridden from the command linestatic final Level
static final long
private InputStream
private Level
private final AtomicBoolean
private int
private long
Fields inherited from interface org.apache.sshd.common.util.logging.SimplifiedLog
EMPTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()
void
close()
createKeyPairs
(String keyType) createKeyPairs
(Collection<String> typeNames) int
getPort()
long
static <S extends SshKeyScanMain>
SinitializeScanner
(S scanner, Collection<String> hosts) boolean
isEnabledLevel
(Level level) boolean
isOpen()
void
protected void
logNegotiationProposal
(String type, Map<org.apache.sshd.common.kex.KexProposalOption, String> proposal) protected void
logSessionEvent
(org.apache.sshd.common.session.Session session, Object event) static void
parseCommandLineArguments
(SshKeyScanMain scanner, String... args) protected void
resolveServerKeys
(org.apache.sshd.client.SshClient client, String host, String kt, List<KeyPair> ids) 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) protected List
<org.apache.sshd.common.NamedFactory<org.apache.sshd.common.signature.Signature>> resolveSignatureFactories
(String keyType) void
sessionClosed
(org.apache.sshd.common.session.Session session) void
sessionCreated
(org.apache.sshd.common.session.Session session) void
sessionEvent
(org.apache.sshd.common.session.Session session, org.apache.sshd.common.session.SessionListener.Event event) void
sessionException
(org.apache.sshd.common.session.Session session, Throwable t) 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) 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) void
setInputStream
(InputStream input) static <S extends SshKeyScanMain>
SsetInputStream
(S scanner, Collection<String> hosts) void
setKeyTypes
(List<String> keyTypes) void
setLogLevel
(Level level) void
setPort
(int port) void
setTimeout
(long timeout) private static String
toString
(SocketAddress addr) boolean
verifyServerKey
(org.apache.sshd.client.session.ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) protected void
writeServerKey
(String remoteLocation, String keyType, PublicKey serverKey) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.sshd.common.session.SessionListener
sessionDisconnect, sessionEstablished, sessionNegotiationOptionsCreated, sessionPeerIdentificationLine, sessionPeerIdentificationReceived, sessionPeerIdentificationSend
Methods 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 key types if not overridden from the command line -
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
- Specified by:
log
in interfaceorg.apache.sshd.common.util.logging.SimplifiedLog
-
isEnabledLevel
- Specified by:
isEnabledLevel
in 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, throws IOExceptionList<org.apache.sshd.common.NamedFactory<org.apache.sshd.common.signature.Signature>>> sigFactories) - Throws:
IOException
-
resolveServerKeys
protected void resolveServerKeys(org.apache.sshd.client.SshClient client, String host, String kt, List<KeyPair> ids) throws Exception - Throws:
Exception
-
sessionCreated
public void sessionCreated(org.apache.sshd.common.session.Session session) - Specified by:
sessionCreated
in 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:
sessionEvent
in interfaceorg.apache.sshd.common.session.SessionListener
-
sessionException
- Specified by:
sessionException
in interfaceorg.apache.sshd.common.session.SessionListener
-
sessionClosed
public void sessionClosed(org.apache.sshd.common.session.Session session) - Specified by:
sessionClosed
in 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:
sessionNegotiationStart
in 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:
sessionNegotiationEnd
in interfaceorg.apache.sshd.common.session.SessionListener
-
logSessionEvent
-
verifyServerKey
public boolean verifyServerKey(org.apache.sshd.client.session.ClientSession sshClientSession, SocketAddress remoteAddress, PublicKey serverKey) - Specified by:
verifyServerKey
in interfaceorg.apache.sshd.client.keyverifier.ServerKeyVerifier
-
writeServerKey
protected void writeServerKey(String remoteLocation, String keyType, PublicKey serverKey) throws Exception - Throws:
Exception
-
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
public boolean isOpen() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in 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
- Throws:
Exception
-