public interface SshClientConnector
Modifier and Type | Method and Description |
---|---|
SshClient |
connect(SshTransport transport,
String username)
Create a new connection to an SSH server over the specified transport.
|
SshClient |
connect(SshTransport transport,
String username,
boolean buffered)
See
connect(SshTransport, String) for full details. |
SshClient |
connect(SshTransport transport,
String username,
boolean buffered,
SshContext context)
See
connect(SshTransport, String) for full details. |
SshClient |
connect(SshTransport transport,
String username,
SshContext context)
See
connect(SshTransport, String) for full details. |
SshClient connect(SshTransport transport, String username) throws SshException
Create a new connection to an SSH server over the specified transport.
This method reads the remote servers identification and determines which
protocol support is required. An SshClient
instance is then
created, initialized and returned. If both protocol versions are
supported by the remote server the connector will always operate using
SSH2.
The SshTransport
interface is used here to allow different types
of transport mechanisms. Typically this would be a Socket however since
this API is targeted at all Java platforms a Socket cannot be used
directly. See the SshTransport
documentation for an example
Socket implementation.
To take advantage of protocol specific features you can test the instance
returned which will either be an Ssh1Client
or
Ssh2Client
.
transport
- the transport for the connection.username
- the name of the user connectingSshException
Ssh1Client
,
Ssh2Client
SshClient connect(SshTransport transport, String username, boolean buffered) throws SshException
connect(SshTransport, String)
for full details. This method
optionally allows you to specify the buffered state of the connection.
When the connection is buffered a background thread is started to act as
a message pump; this has the benefit of routing data as soon as it
arrives and helps in circumstances where you require a channel to fill up
with data without calling its InputStream's read method. This also will
enable the InputStreams available method to work as expected.transport
- SshTransportusername
- Stringbuffered
- booleanSshException
SshClient connect(SshTransport transport, String username, SshContext context) throws SshException
connect(SshTransport, String)
for full details. This method
optionally allows you to specify a context to use. Normally you would
reused an SshConnector
instead of calling this method directly.transport
- SshTransportusername
- Stringcontext
- SshContextSshException
SshClient connect(SshTransport transport, String username, boolean buffered, SshContext context) throws SshException
connect(SshTransport, String)
for full details.
This method optionally allows you to specify the buffered state of the connection. When the connection is buffered a background thread is started to act as a message pump; this has the benefit of routing data as soon as it arrives and helps in circumstances where you require a channel to fill up with data without calling its InputStream's read method. This also will enable the InputStreams available method to work as expected.
This method also allows you to specify a context to use. Normally you
would reuse an SshConnector
instead of calling this method
directly.
transport
- SshTransportusername
- Stringbuffered
- booleancontext
- SshContextSshException
Copyright © 2024. All rights reserved.