Package com.sshtools.client
Class SshClient
java.lang.Object
com.sshtools.client.SshClient
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic final classstatic final class -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanauthenticate(ClientAuthenticator authenticator, long timeout) voidclose()voidprotected final Connection<SshClientContext>doConnect(String hostname, int port, SshClientContext sshContext, long connectTimeout, List<String> keys) protected <T extends Task>
TdoTask(T task, long timeout) executeCommand(String cmd) executeCommand(String cmd, long timeout) executeCommand(String cmd, long timeout, String charset) executeCommand(String cmd, String charset) intintexecuteCommandWithResult(String cmd, StringBuffer buffer) intexecuteCommandWithResult(String cmd, StringBuffer buffer, long timeout) intexecuteCommandWithResult(String cmd, StringBuffer buffer, long timeout, String charset) intexecuteCommandWithResult(String cmd, StringBuffer buffer, String charset) voidvoidgetHost()intgetPort()String[]booleanbooleanstatic voidopenRemoteClient(String hostname, int port, String username) openSessionChannel(boolean autoConsume) openSessionChannel(long timeout) openSessionChannel(long timeout, boolean autoConsume) voidvoidvoid<T extends Task>
voidrunTask(T task) <T extends Task>
voidrunTask(T task, long timeout) intstartLocalForwarding(String addressToBind, int portToBind, String destinationHost, int destinationPort) intstartLocalForwarding(String addressToBind, String destinationHost) intstartRemoteForwarding(String addressToBind, int portToBind, String destinationHost, int destinationPort) intstartRemoteForwarding(String addressToBind, String destinationHost) voidvoidstopLocalForwarding(String addressToBind, int portToBind) voidvoidstopRemoteForwarding(String addressToBind, int portToBind)
-
Field Details
-
GUEST_USERNAME
-
DEFAULT_CONNECT_TIMEOUT
public static final long DEFAULT_CONNECT_TIMEOUT
-
-
Method Details
-
doConnect
protected final Connection<SshClientContext> doConnect(String hostname, int port, SshClientContext sshContext, long connectTimeout, List<String> keys) throws SshException, IOException - Throws:
SshExceptionIOException
-
addTask
- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getContext
-
getConnection
-
getForwardingPolicy
-
startLocalForwarding
public int startLocalForwarding(String addressToBind, String destinationHost) throws UnauthorizedException, SshException - Throws:
UnauthorizedExceptionSshException
-
startLocalForwarding
public int startLocalForwarding(String addressToBind, int portToBind, String destinationHost, int destinationPort) throws UnauthorizedException, SshException - Throws:
UnauthorizedExceptionSshException
-
stopLocalForwarding
-
stopLocalForwarding
public void stopLocalForwarding() -
startRemoteForwarding
public int startRemoteForwarding(String addressToBind, int portToBind, String destinationHost, int destinationPort) throws SshException - Throws:
SshException
-
startRemoteForwarding
- Throws:
SshException
-
stopRemoteForwarding
- Throws:
SshException
-
stopRemoteForwarding
- Throws:
SshException
-
isConnected
public boolean isConnected() -
disconnect
public void disconnect() -
doTask
- Throws:
IOException
-
getFile
- Throws:
IOException
-
getFile
- Throws:
IOException
-
getFile
- Throws:
IOException
-
getFile
- Throws:
IOException
-
putFile
- Throws:
IOException
-
putFile
- Throws:
IOException
-
putFile
- Throws:
IOException
-
executeCommand
- Throws:
IOException
-
executeCommand
- Throws:
IOException
-
executeCommand
- Throws:
IOException
-
executeCommand
- Throws:
IOException
-
executeCommandWithResult
- Throws:
IOException
-
executeCommandWithResult
- Throws:
IOException
-
executeCommandWithResult
public int executeCommandWithResult(String cmd, StringBuffer buffer, long timeout) throws IOException - Throws:
IOException
-
executeCommandWithResult
public int executeCommandWithResult(String cmd, StringBuffer buffer, String charset) throws IOException - Throws:
IOException
-
executeCommandWithResult
public int executeCommandWithResult(String cmd, StringBuffer buffer, long timeout, String charset) throws IOException - Throws:
IOException
-
getAuthenticationMethods
-
authenticate
public boolean authenticate(ClientAuthenticator authenticator, long timeout) throws IOException, SshException - Throws:
IOExceptionSshException
-
isAuthenticated
public boolean isAuthenticated() -
runTask
- Throws:
IOException
-
runTask
- Throws:
IOException
-
getRemotePublicKeys
-
getRemoteIdentification
-
getLocalIdentification
-
getHost
-
getHostKey
-
openSessionChannel
- Throws:
SshException
-
openSessionChannel
- Throws:
SshException
-
openSessionChannel
- Throws:
SshException
-
openSessionChannel
- Throws:
SshException
-
openRemoteClient
public SshClient openRemoteClient(String hostname, int port, String username) throws SshException, IOException, UnauthorizedException -
getPort
public int getPort() -
main
- Throws:
IOExceptionSshException
-