org.apache.sshd.client.SshClient . Once the session has been
created, the user has to authenticate using either addPasswordIdentity(String) or
addPublicKeyIdentity(java.security.KeyPair) followed by a call to auth().
From this session, channels can be created using the createChannel(String) method. Multiple channels can be
created on a given session concurrently.
When using the client in an interactive mode, the waitFor(Collection, long) method can be used to listen to
specific events such as the session being established, authenticated or closed.
When a given session is no longer used, it must be closed using the close(boolean) method.
| Modifier and Type | Class and Description |
|---|---|
| public static enum |
| Modifier and Type | Field and Description |
|---|---|
| public static final Set |
| Modifier and Type | Method and Description |
|---|---|
| public AuthFuture | |
| public ClientChannel | Returns: The createdClientChannelThe channel type type)Create a channel of the given type. |
| public ClientChannel | Returns: The createdClientChannelThe channel type type, String The channel sub-type subType)Create a channel of the given type and sub-type. |
| public ChannelDirectTcpip | Returns: The createdChannelDirectTcpipThe local address local, SshdSocketAddress The remote address remote)Create a direct tcp-ip channel which can be used to stream data to a remote port from the server. |
| public default DynamicPortForwardingTracker | Returns: The tracker instanceThe local address local)Starts a dynamic port forwarding and returns a tracker that stops the forwarding when the |
| public default ChannelExec | Returns: The createdChannelExecThe command to execute command)Create a channel to execute a command using default PTY settings and environment. |
| public default ChannelExec | Returns: The createdChannelExecThe command to execute command, PtyChannelConfigurationHolder The PTY configuration to use - if ptyConfig, Map<String, ?> null then internal defaults are usedExtra environment configuration to be transmitted to the server - ignored if
env)null/empty.Create a channel to execute a command using specific PTY settings and/or environment. |
| public ChannelExec | Returns: The createdChannelExecThe command to execute command, Charset The charset, PtyChannelConfigurationHolder Charset to use for sending the command stringThe PTY configuration to use - if ptyConfig, Map<String, ?> null then internal defaults are usedExtra environment configuration to be transmitted to the server - ignored if
env)null/empty.Create a channel to execute a command using specific PTY settings and/or environment. |
| public ChannelExec | Returns: The createdChannelExecThe command to execute command, PtyChannelConfigurationHolder The PTY configuration to use - if ptyConfig, Map<String, ?> null then internal defaults are usedExtra environment configuration to be transmitted to the server - ignored if
env)null/empty.Create a channel to execute a command using specific PTY settings and/or environment. |
| public default ExplicitPortForwardingTracker | Returns: The tracker instanceThe local port - if zero one is allocated localPort, SshdSocketAddress The remote address remote)Starts a local port forwarding and returns a tracker that stops the forwarding when the |
| public default ExplicitPortForwardingTracker | Returns: The tracker instanceThe local address local, SshdSocketAddress The remote address remote)Starts a local port forwarding and returns a tracker that stops the forwarding when the |
| public default ExplicitPortForwardingTracker | Returns: The tracker instanceThe remote address remote, SshdSocketAddress The local address local)Starts a remote port forwarding and returns a tracker that stops the forwarding when the |
| public default ChannelShell | Returns: The createdChannelShellCreate a channel to start a shell using default PTY settings and environment. |
| public ChannelShell | Returns: The createdChannelShellThe PTY configuration to use - if ptyConfig, Map<String, ?> null then internal defaults are usedExtra environment configuration to be transmitted to the server - ignored if
env)null/empty.Create a channel to start a shell using specific PTY settings and/or environment. |
| public ChannelSubsystem | Returns: The createdChannelSubsystemThe subsystem name subsystem)Create a subsystem channel. |
| public default String | Returns: The command's standard output result (assumed to be in US-ASCII)The command to execute command)Execute a command that requires no input and returns its output |
| public default String | Returns: The command's standard output resultThe command to execute - without a terminating LF command, OutputStream Standard error output stream - if stderr, Charset null then error stream data is ignoredNote if the stream is not The command charset)Charset for input/output/error - if null then US_ASCII is assumedExecute a command that requires no input and returns its output |
| public default void | executeRemoteCommand(String
The command to execute - without a terminating LF command, OutputStream Standard output stream - if stdout, OutputStream null then stream data is ignoredNote if the
stream is not Error output stream - if stderr, Charset null then stream data is ignoredNote if the stream
is not The command charset)Charset for output/error - if null then US_ASCII is assumedExecute a command that requires no input and redirects its STDOUT/STDERR streams to the user-provided ones |
| public SocketAddress | Returns: The original requested addressReturns the original address (after having been translated through host configuration entries if any) that was request to connect. |
| public AttributeRepository | Returns: The "context" data provided when session connection was established -null if none.
|
| public ClientFactoryManager | Returns: The ClientFactoryManager for this session.Redeclares org.
|
| public Map | Returns: The metadataMap - Note: access to the map is not synchronized in any way - up to
the user to take care of mutual exclusion if necessaryAccess to the metadata. |
| public PublicKey | |
| public Set | |
| public static Iterator | Returns: The wrapping iteratorThe session)ClientSession - ignored if null (i.e., empty iterator
returned)Creates a "unified" |
| public static KeyIdentityProvider | Returns: The wrapping KeyIdentityProviderThe session)ClientSession - ignored if null (i.e., empty iterator returned)Creates a "unified" |
| public KeyExchangeFuture | Returns: anKeyExchangeFuture that can be used to wait for the exchange to be finishedSwitch to a none cipher for performance. |
| public Set | Returns: The actual state that was detected either due to the mask yielding one of the states or due to timeout (in which case theClientSessionEvent#TIMEOUT value is set)The request mask,ClientSessionEvents maskWait time in milliseconds - non-positive means forever timeout)Wait for any one of a specific state to be signaled. |
| public default Set | Returns: The actual state that was detected either due to the mask yielding one of the states or due to timeout (in which case theClientSessionEvent#TIMEOUT value is set)The request mask,ClientSessionEvents maskWait time - null means forever timeout)Wait for any one of a specific state to be signaled. |
| REMOTE_COMMAND_WAIT_EVENTS | back to summary |
|---|---|
| public static final Set<ClientChannelEvent> REMOTE_COMMAND_WAIT_EVENTS | |
| auth | back to summary |
|---|---|
| public AuthFuture auth() throws IOException Starts the authentication process. User identities will be tried until the server successfully authenticate the
user. User identities must be provided before calling this method using
| |
| createChannel | back to summary |
|---|---|
| public ClientChannel createChannel(String type) throws IOException Create a channel of the given type. Same as calling
| |
| createChannel | back to summary |
|---|---|
| public ClientChannel createChannel(String type, String subType) throws IOException Create a channel of the given type and sub-type.
| |
| createDirectTcpipChannel | back to summary |
|---|---|
| public ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws IOException Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.
| |
| createDynamicPortForwardingTracker | back to summary |
|---|---|
| public default DynamicPortForwardingTracker createDynamicPortForwardingTracker(SshdSocketAddress local) throws IOException Starts a dynamic port forwarding and returns a tracker that stops the forwarding when the
| |
| createExecChannel | back to summary |
|---|---|
| public default ChannelExec createExecChannel(String command) throws IOException Create a channel to execute a command using default PTY settings and environment.
| |
| createExecChannel | back to summary |
|---|---|
| public default ChannelExec createExecChannel(String command, PtyChannelConfigurationHolder ptyConfig, Map<String, ?> env) throws IOException Create a channel to execute a command using specific PTY settings and/or environment.
| |
| createExecChannel | back to summary |
|---|---|
| public ChannelExec createExecChannel(String command, Charset charset, PtyChannelConfigurationHolder ptyConfig, Map<String, ?> env) throws IOException Create a channel to execute a command using specific PTY settings and/or environment.
| |
| createExecChannel | back to summary |
|---|---|
| public ChannelExec createExecChannel(byte[] command, PtyChannelConfigurationHolder ptyConfig, Map<String, ?> env) throws IOException Create a channel to execute a command using specific PTY settings and/or environment.
| |
| createLocalPortForwardingTracker | back to summary |
|---|---|
| public default ExplicitPortForwardingTracker createLocalPortForwardingTracker(int localPort, SshdSocketAddress remote) throws IOException Starts a local port forwarding and returns a tracker that stops the forwarding when the
| |
| createLocalPortForwardingTracker | back to summary |
|---|---|
| public default ExplicitPortForwardingTracker createLocalPortForwardingTracker(SshdSocketAddress local, SshdSocketAddress remote) throws IOException Starts a local port forwarding and returns a tracker that stops the forwarding when the
| |
| createRemotePortForwardingTracker | back to summary |
|---|---|
| public default ExplicitPortForwardingTracker createRemotePortForwardingTracker(SshdSocketAddress remote, SshdSocketAddress local) throws IOException Starts a remote port forwarding and returns a tracker that stops the forwarding when the
| |
| createShellChannel | back to summary |
|---|---|
| public default ChannelShell createShellChannel() throws IOException Create a channel to start a shell using default PTY settings and environment.
| |
| createShellChannel | back to summary |
|---|---|
| public ChannelShell createShellChannel(PtyChannelConfigurationHolder ptyConfig, Map<String, ?> env) throws IOException Create a channel to start a shell using specific PTY settings and/or environment.
| |
| createSubsystemChannel | back to summary |
|---|---|
| public ChannelSubsystem createSubsystemChannel(String subsystem) throws IOException Create a subsystem channel.
| |
| executeRemoteCommand | back to summary |
|---|---|
| public default String executeRemoteCommand(String command) throws IOException Execute a command that requires no input and returns its output
| |
| executeRemoteCommand | back to summary |
|---|---|
| public default String executeRemoteCommand(String command, OutputStream stderr, Charset charset) throws IOException Execute a command that requires no input and returns its output
| |
| executeRemoteCommand | back to summary |
|---|---|
| public default void executeRemoteCommand(String command, OutputStream stdout, OutputStream stderr, Charset charset) throws IOException Execute a command that requires no input and redirects its STDOUT/STDERR streams to the user-provided ones
| |
| getConnectAddress | back to summary |
|---|---|
| public SocketAddress getConnectAddress() Returns the original address (after having been translated through host configuration entries if any) that was request to connect. It contains the original host or address string that was used Note this may be
different than the result of the
| |
| getConnectionContext | back to summary |
|---|---|
public AttributeRepository getConnectionContext()
| |
| getFactoryManager | back to summary |
|---|---|
| public ClientFactoryManager getFactoryManager() Redeclares org.
| |
| getMetadataMap | back to summary |
|---|---|
| public Map Access to the metadata. | |
| getServerKey | back to summary |
|---|---|
| public PublicKey getServerKey() Retrieves the server's key | |
| getSessionState | back to summary |
|---|---|
public Set
| |
| passwordIteratorOf | back to summary |
|---|---|
| public static Iterator Creates a "unified"
| |
| providerOf | back to summary |
|---|---|
| public static KeyIdentityProvider providerOf(ClientSession session) Creates a "unified"
| |
| switchToNoneCipher | back to summary |
|---|---|
| public KeyExchangeFuture switchToNoneCipher() throws IOException Switch to a none cipher for performance. This should be done after the authentication phase has been performed. After such a switch, interactive channels are not allowed anymore. Both client and server must have been configured to support the none cipher. If that's not the case, the returned future will be set with an exception.
| |
| waitFor | back to summary |
|---|---|
| public Set Wait for any one of a specific state to be signaled.
| |
| waitFor | back to summary |
|---|---|
| public default Set Wait for any one of a specific state to be signaled.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final ClientSession. | |
| public static final ClientSession. | |
| public static final ClientSession. | |
| public static final ClientSession. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ClientSession. | |
| public static ClientSession. |
| AUTHED | back to summary |
|---|---|
| public static final ClientSession. | |
| CLOSED | back to summary |
|---|---|
| public static final ClientSession. | |
| TIMEOUT | back to summary |
|---|---|
| public static final ClientSession. | |
| WAIT_AUTH | back to summary |
|---|---|
| public static final ClientSession. | |
| ClientSessionEvent | back to summary |
|---|---|
| private ClientSessionEvent() | |
| valueOf | back to summary |
|---|---|
| public static ClientSession. | |
| values | back to summary |
|---|---|
| public static ClientSession. | |