public class IpClientSsh extends IpClient
Example usage:
// connection information for SSH server
String sshHostname = "10.0.0.1";
String sshUsername = "jsmith";
String sshPassword = "secret";
try {
// create new SshParameters instance
SshParameters sshParams = new SshParameters(sshHostname,sshUsername,sshPassword);
// create new IpClient instance with SSH parameters, hostname, port and
timeout arguments
IpClientSsh client = new IpClientSsh(sshParams,"10.0.0.1",53,5000);
// establish connection with server
client.connect();
// obtain OutputStream for sending data to server
OutputStream out = client.getOutputStream();
// obtain InputStream for reading data from server
InputStream in = client.getInputStream();
// disconnect from server
client.disconnect();
} catch(IpClientException ipe) {
ipe.printStackTrace();
}
| Constructor and Description |
|---|
IpClientSsh(SshParameters parameters,
java.lang.String hostname,
int port)
Creates a new IpClientSsh instance.
|
IpClientSsh(SshParameters parameters,
java.lang.String hostname,
int port,
int timeout)
Creates a new IpClientSsh instance.
|
IpClientSsh(SshParameters parameters,
java.lang.String hostname,
int port,
int timeout,
SshConfiguration configuration)
Creates new IpClientSsh instance.
|
| Modifier and Type | Method and Description |
|---|---|
IpClientSsh |
connect()
Establishes connection with SSH server, performs authentication and
creates tunnel to hostname and port provided in constructor.
|
void |
disconnect()
Closes tunnel between SSH server and host and closes connection to SSH
server.
|
SshHostKeys |
getHostKeys()
Returns SSH host keys for further use.
|
java.net.Socket |
getSocket()
Gets Socket established after invoking the IpClient#connect method.
|
addIpClientListener, clearProxySettings, close, getConnectTimeout, getInputStream, getOutputStream, getReadTimeout, removeIpClientListener, setConnectTimeout, setInputStream, setOutputStream, setProxyAuthentication, setProxyHost, setProxyType, setReadTimeout, setSocketpublic IpClientSsh(SshParameters parameters, java.lang.String hostname, int port, int timeout, SshConfiguration configuration)
parameters - the SSH parameters used in establishing secure connectionhostname - the hostname of server to connect toport - the port of server to connect totimeout - the timeout period to wait before connection to server is establishedconfiguration - configuration parameterspublic IpClientSsh(SshParameters parameters, java.lang.String hostname, int port, int timeout)
hostname - the hostname of server to connect toport - the port of server to connect totimeout - the timeout period to wait before connection to server is establishedparameters - the SSH parameters used in establishing secure connectionpublic IpClientSsh(SshParameters parameters, java.lang.String hostname, int port)
hostname - the hostname of server to connect toport - the port of server to connect toparameters - the SSH parameters used in establishing secure
connectionpublic IpClientSsh connect() throws IpClientException
connect in class IpClientIpClientException - if an error occurs while establishing
connectionpublic void disconnect()
throws IpClientException
disconnect in class IpClientIpClientException - if an I/O related error occurspublic java.net.Socket getSocket()
public SshHostKeys getHostKeys()
null if keys are not availableCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved