public interface SshClient
| Modifier and Type | Method and Description |
|---|---|
void |
addChannelHandler(SshChannelHandler channelHandler)
Adds a channel handler to those invoked when custom channel creation
requests are received.
|
void |
addPortForwardListener(SshPortForwardListener listener)
Add a listener that is notified when channels are opened on this port
forward.
|
boolean |
authenticate(SshAuthenticator authenticator)
Authenticate using a single authenticator.
|
boolean |
authenticate(SshAuthenticator[] authenticators)
Authenticate.
|
void |
connect(java.lang.String username,
java.lang.String hostname,
int port)
Connect to specified host and port using the provided username.
|
SshExtendedStreamChannel |
createCommand(java.lang.String command)
Execute a command on the remote server.
|
SshPortForward |
createLocalForward(java.lang.String localBindAddress,
int localBindPort,
java.lang.String targetAddress,
int targetPort)
Create a local forward.
|
SshPublicKeySubsystem |
createPublicKeySubsystem()
Create an instance of a
SshPublicKeySubsystem, if the provider
supports it. |
SshPortForward |
createRemoteForward(java.lang.String remoteBindAddress,
int remoteBindPort,
java.lang.String targetAddress,
int targetPort)
Create a remote forward.
|
SshSCPClient |
createSCPClient()
Create a new SCP client.
|
SftpClient |
createSftpClient()
Create a new SFTP client that may be used to perform file operations.
|
SshShell |
createShell(java.lang.String termType,
int cols,
int rows,
int pixWidth,
int pixHeight,
byte[] terminalModes)
Create a new shell.
|
javax.net.SocketFactory |
createTunneledSocketFactory()
Create a
SocketFactory whose connections are actually tunneled
over this SSH connection and made from the remote machine. |
void |
disconnect()
Disconnect this client.
|
int |
getChannelCount()
Get the number of channels that are currently open.
|
SshConfiguration |
getConfiguration()
Get the configuration this client is using
|
SshProvider |
getProvider()
Get the provider that created this client.
|
java.lang.String |
getRemoteIdentification()
Get the remote server identification string.
|
int |
getRemoteProtocolVersion()
Get the protocol version.
|
int |
getTimeout()
Get the timeout on the underlying transport (usually a Socket, if
supported).
|
java.lang.String |
getUsername()
Get the currently authenticated user.
|
void |
init(SshProvider provider)
Called after instantiation to initialise the client and supply the
provider that created it.
|
boolean |
isAuthenticated()
Get if the client is currently authenticated.
|
boolean |
isConnected()
Get if the client is currently connected.
|
void |
removeChannelHandler(SshChannelHandler channelHandler)
Remove a channel handler from the list of those invoked when custom channel creation
requests are received.
|
void |
removePortForwardListener(SshPortForwardListener listener)
Remove a listener that is notified when channels are opened on this port
forward.
|
void |
setTimeout(int timeout)
Set the timeout on the underlying transport (usually a Socket, if
supported).
|
SshConfiguration getConfiguration()
void init(SshProvider provider)
provider - providerSshProvider getProvider()
void connect(java.lang.String username,
java.lang.String hostname,
int port)
throws SshException
username - user namehostname - host nameport - portSshException - on any errorboolean authenticate(SshAuthenticator[] authenticators) throws SshException
true is return or an exception is thrown.authenticators - authenticators.true when full authenticated, or false
if more authentication is requiredSshExceptionboolean authenticate(SshAuthenticator authenticator) throws SshException
authenticate(SshAuthenticator[]).authenticator - authenticator.SshException#authenticate(SshAuthenticator[])}SshShell createShell(java.lang.String termType, int cols, int rows, int pixWidth, int pixHeight, byte[] terminalModes) throws SshException
Note, this method does not actually start the shell, you must call
SshLifecycleComponent.open() to do that.
Remember to close the shell when you are finished with it using
SshLifecycleComponent.close().
termType - terminal type, or use null to NOT request a
pseudo terminalcols - width of terminal in characters (use zero if not pseudo
terminal should be requested)rows - height of terminal in characters (use zero if not pseudo
terminal should be requested)pixWidth - width of terminal in pixels (if known, otherwise use
zero)pixHeight - height of terminal in pixels (if known, otherwise use
zero)terminalModes - terminal modes (or null or empty array)SshExceptionSshPortForward createLocalForward(java.lang.String localBindAddress, int localBindPort, java.lang.String targetAddress, int targetPort) throws SshException
Once you have created the SshPortForward object, you must start
tunnel using SshPortForward.open(). When you have finished with
the tunnel, call SshPortForward.close() (closed tunnels may be
re-opened by calling the SshPortForward.open() method again).
localBindAddress - local address to bind to. Use null
to bind to all addresses. Note, this may not be supported by
all implementations.localBindPort - local port to listen ontargetAddress - remote host to tunnel totargetPort - remote port to tunnel toSshException - on any errorSshPortForward createRemoteForward(java.lang.String remoteBindAddress, int remoteBindPort, java.lang.String targetAddress, int targetPort) throws SshException
Once you have created the SshPortForward object, you must start
tunnel using SshPortForward.open(). When you have finished with
the tunnel, call SshPortForward.close() (closed tunnels may be
re-opened by calling the SshPortForward.open() method again).
remoteBindAddress - the address on the remote server to listen. This
must either be null to bind to all address on
that server, or a single address that exists on that server
(including 127.0.0.1).remoteBindPort - remote port to tunnel totargetAddress - local address to bind to. Use null to
bind to all addresses. Note, this may not be supported by all
implementations.targetPort - local port to listen onSshException - on any errorSshExtendedStreamChannel createCommand(java.lang.String command) throws SshException
Note, this method does not actually start the command, you must call
SshLifecycleComponent.open() to do that.
Remember to close the channel when you are finished with it using
SshLifecycleComponent.close().
command - command to executeSshException - on any errorjavax.net.SocketFactory createTunneledSocketFactory()
throws SshException
SocketFactory whose connections are actually tunneled
over this SSH connection and made from the remote machine. This actually
makes use of local port forward, but instead of setting up a local server
socket, the tunnels are accessable as Socket objects.SshExceptionSshSCPClient createSCPClient() throws SshException
createSftpClient().SshException - on any errorSftpClient createSftpClient() throws SshException
Note, this method does not actually start the client, you must call
SshLifecycleComponent.open() to do that.
Remember to close the client when you are finished with it using
SshLifecycleComponent.close().
SshExceptionSshPublicKeySubsystem createPublicKeySubsystem() throws SshException
SshPublicKeySubsystem, if the provider
supports it.
Note, this method does not actually start the subsystems, you must call
SshLifecycleComponent.open() to do that.
Remember to close the subsystem when you are finished with it using
SshLifecycleComponent.close().
SshExceptionjava.lang.UnsupportedOperationException - if no supportedvoid disconnect()
throws SshException
SshExceptionboolean isConnected()
isAuthenticated()boolean isAuthenticated()
isConnected()java.lang.String getRemoteIdentification()
java.lang.IllegalStateException - if not connectedint getRemoteProtocolVersion()
SshConfiguration.SSH1_ONLY or SshConfiguration.SSH2_ONLY.java.lang.IllegalStateException - if not connectedjava.lang.String getUsername()
int getChannelCount()
java.lang.IllegalStateException - if not connectedvoid addPortForwardListener(SshPortForwardListener listener)
listener - listener to addvoid removePortForwardListener(SshPortForwardListener listener)
listener - listener to removevoid setTimeout(int timeout)
throws java.io.IOException
timeout - timeoutjava.io.IOExceptionint getTimeout()
throws java.io.IOException
java.io.IOExceptionvoid addChannelHandler(SshChannelHandler channelHandler) throws SshException
channelHandler - channel handler to addSshExceptionvoid removeChannelHandler(SshChannelHandler channelHandler) throws SshException
channelHandler - channel handler to removeSshExceptionCopyright © 2018. All rights reserved.