SshSessionFactory that uses Apache MINA sshd. Classes from Apache
MINA sshd are kept private to avoid API evolution problems when Apache MINA
sshd interfaces change.
| Modifier and Type | Class and Description |
|---|---|
| private static class | SshdSessionFactory.
A simple general map key. |
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicBoolean | |
| private final Map | |
| private final Map | |
| private final Map | |
| private File | |
| private final KeyCache | |
| private static final String | |
| private final ProxyDataFactory | |
| private final Set | |
| private File |
| Access | Constructor and Description |
|---|---|
| public | SshdSessionFactory()
Creates a new |
| public | SshdSessionFactory(KeyCache
KeyCache to use for caching ssh keys, or null
to not use a key cacheProxyDataFactory to use, or null to not use a
proxy database (in which case connections through proxies will
not be possible)Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. Closes this stream and releases any system resources associated with it. |
| private FilePasswordProvider | Returns: a newFilePasswordProviderproviding the providerFactory)KeyPasswordProvider to delegate toCreates a |
| protected KeyPasswordProvider | createKeyPasswordProvider(CredentialsProvider
the provider)CredentialsProvider to delegate to for user
interactionsCreates a |
| protected ServerKeyDatabase | Returns: theServerKeyDatabasehome directory to use for ~ replacement homeDir, File representing ~/.ssh/ sshDir)Creates a |
| protected SshConfigStore | createSshConfigStore(File
may be used for ~-replacements by the returned config store homeDir, File to use, or configFile, String null if noneuser name of the current user on the local OS localUserName)Obtains a |
| protected ConnectorFactory | Returns: the factory, ornull if no SSH agent support is desiredGets a |
| protected List | Returns: a possibly empty list of paths containing default identities (private keys)the directory that represents ~/.ssh/ sshDir)Gets a list of default identities, i.e., private key files that shall always be tried for public key authentication. |
| protected Iterable | Returns: anIterable over the default keysto look in for keys sshDir)Determines the default keys. |
| protected List | Returns: the possibly empty list of default known host file paths.directory containing ssh configurations sshDir)Gets the list of default user known hosts files. |
| protected String | Returns: a comma-separated list of mechanism names, ornull if
noneGets the list of default preferred authentication mechanisms. |
| public File | Returns: the directory, ornull if not setRetrieves the global user home directory |
| private HostConfigEntryResolver | Returns: the resolverhome directory to use for ~ replacement homeDir, File to use for looking for the config file sshDir)Obtain a |
| protected final KeyCache | |
| protected ServerKeyDatabase | Returns: theServerKeyDatabasehome directory to use for ~ replacement homeDir, File representing ~/.ssh/ sshDir)Obtains a |
| public SshdSession | getSession(URIish
URI of the remote host to connect to uri, CredentialsProvider provider to support authentication, may be credentialsProvider, FS null if no
user input for authentication is neededthe file system abstraction to use for certain file
operations, such as reading configuration files fs, int connection timeout for creating the session, in milliseconds tms)Implements abstract org. Opens (or reuses) a session to a host. |
| private static List | Returns: a list of supported signature factoriesApache MINA sshd 2.6.0 has removed DSA, DSA_CERT and RSA_CERT. |
| protected File | Returns: the file (need not exist), ornull if no config file
shall be usedrepresenting ~/.ssh/ sshDir)Determines the ssh config file. |
| public File | |
| public String | getType()
Implements abstract org. The name of the type of session factory. |
| private List | Returns: the non-empty list of factories.Gets the user authentication mechanisms (or rather, factories for them). |
| private Supplier | |
| private void | |
| public void | |
| public void | |
| private KeyIdentityProvider | toKeyIdentityProvider(Iterable<KeyPair>
to provide via the returned keys)KeyIdentityProviderConverts an |
| private void |
| closing | back to summary |
|---|---|
| private final AtomicBoolean closing | |
| defaultHostConfigEntryResolver | back to summary |
|---|---|
| private final Map<SshdSessionFactory. | |
| defaultKeys | back to summary |
|---|---|
| private final Map<SshdSessionFactory. | |
| defaultServerKeyDatabase | back to summary |
|---|---|
| private final Map<SshdSessionFactory. | |
| homeDirectory | back to summary |
|---|---|
| private File homeDirectory | |
| keyCache | back to summary |
|---|---|
| private final KeyCache keyCache | |
| MINA_SSHD | back to summary |
|---|---|
| private static final String MINA_SSHD | |
| proxies | back to summary |
|---|---|
| private final ProxyDataFactory proxies | |
| sessions | back to summary |
|---|---|
| private final Set<SshdSession> sessions | |
| sshDirectory | back to summary |
|---|---|
| private File sshDirectory | |
| SshdSessionFactory | back to summary |
|---|---|
| public SshdSessionFactory() Creates a new | |
| SshdSessionFactory | back to summary |
|---|---|
| public SshdSessionFactory(KeyCache keyCache, ProxyDataFactory proxies) Creates a new
Caching ssh keys in memory for an extended period of time is generally
considered bad practice, but there may be circumstances where using a
Note that the underlying ssh library (Apache MINA sshd) may or may not
keep ssh keys in memory for unspecified periods of time irrespective of
the use of a
By default, the factory uses the
| |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| createFilePasswordProvider | back to summary |
|---|---|
| private FilePasswordProvider createFilePasswordProvider(Supplier<KeyPasswordProvider> providerFactory) Creates a
| |
| createKeyPasswordProvider | back to summary |
|---|---|
| protected KeyPasswordProvider createKeyPasswordProvider(CredentialsProvider provider) Creates a
| |
| createServerKeyDatabase | back to summary |
|---|---|
| protected ServerKeyDatabase createServerKeyDatabase(File homeDir, File sshDir) Creates a
| |
| createSshConfigStore | back to summary |
|---|---|
| protected SshConfigStore createSshConfigStore(File homeDir, File configFile, String localUserName) Obtains a
| |
| getConnectorFactory | back to summary |
|---|---|
| protected ConnectorFactory getConnectorFactory() Gets a
The default implementation uses
| |
| getDefaultIdentities | back to summary |
|---|---|
| protected List Gets a list of default identities, i.e., private key files that shall
always be tried for public key authentication. Typically those are
~/.ssh/id_dsa, ~/.ssh/id_rsa, and so on. The default implementation
returns the files defined in | |
| getDefaultKeys | back to summary |
|---|---|
| protected Iterable Determines the default keys. The default implementation will lazy load
the
Subclasses may override and return an
The default implementation uses exactly this mechanism; class
If the | |
| getDefaultKnownHostsFiles | back to summary |
|---|---|
| protected List Gets the list of default user known hosts files. The default returns
~/.ssh/known_hosts and ~/.ssh/known_hosts2. The ssh config
| |
| getDefaultPreferredAuthentications | back to summary |
|---|---|
| protected String getDefaultPreferredAuthentications() Gets the list of default preferred authentication mechanisms. If
| |
| getHomeDirectory | back to summary |
|---|---|
| public File getHomeDirectory() Retrieves the global user home directory
| |
| getHostConfigEntryResolver | back to summary |
|---|---|
| private HostConfigEntryResolver getHostConfigEntryResolver(File homeDir, File sshDir) Obtain a
| |
| getKeyCache | back to summary |
|---|---|
| protected final KeyCache getKeyCache() Obtains the | |
| getServerKeyDatabase | back to summary |
|---|---|
| protected ServerKeyDatabase getServerKeyDatabase(File homeDir, File sshDir) Obtains a
| |
| getSession | back to summary |
|---|---|
| public SshdSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException Implements abstract org. Doc from org. Opens (or reuses) a session to a host. The returned session is connected and authenticated and is ready for further use.
| |
| getSignatureFactories | back to summary |
|---|---|
| private static List Apache MINA sshd 2.6.0 has removed DSA, DSA_CERT and RSA_CERT. We have to set it up explicitly to still allow users to connect with DSA keys.
| |
| getSshConfig | back to summary |
|---|---|
| protected File getSshConfig(File sshDir) Determines the ssh config file. The default implementation returns
~/.ssh/config. If the file does not exist and is created later it will be
picked up. To not use a config file at all, return | |
| getSshDirectory | back to summary |
|---|---|
| public File getSshDirectory() Retrieves the global .ssh directory
| |
| getType | back to summary |
|---|---|
| public String getType() Implements abstract org. Doc from org. The name of the type of session factory. | |
| getUserAuthFactories | back to summary |
|---|---|
| private List Gets the user authentication mechanisms (or rather, factories for them).
By default this returns gssapi-with-mic, public-key, password, and
keyboard-interactive, in that order. The order is only significant if the
ssh config does not set
| |
| newKeyPasswordProvider | back to summary |
|---|---|
| private Supplier | |
| register | back to summary |
|---|---|
| private void register(SshdSession newSession) throws IOException | |
| setHomeDirectory | back to summary |
|---|---|
| public void setHomeDirectory(File homeDir) Set a global directory to use as the user's home directory
| |
| setSshDirectory | back to summary |
|---|---|
| public void setSshDirectory(File sshDir) Set a global directory to use as the .ssh directory
| |
| toKeyIdentityProvider | back to summary |
|---|---|
| private KeyIdentityProvider toKeyIdentityProvider(Iterable<KeyPair> keys) Converts an
| |
| unregister | back to summary |
|---|---|
| private void unregister(SshdSession oldSession) | |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public int |
| objects | back to summary |
|---|---|
| private Object[] objects | |
| Tuple | back to summary |
|---|---|
| public Tuple(Object[] objects) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |