|
Establishing a connection |
|
You may establish a secure connection using the IpClientSsh and com.jscape.inet.ssh.util.SshParameters classes. The IpClientSsh class is a subclass of the com.jscape.inet.ipclient.IpClient class making all methods in this class available for use. The SshParameters class will contain all information needed to connect and authenticate with your SSH server for use in creating a secure tunnel.
Example
The example below demonstrates establishing a secure tunnel to the POP (Post Office Protocol) service running on the host myhost.com. This is an example only as it does not provide information on authenticating with the POP server or retrieving email.
// SSH hostname
String sshHostname = "myhost.com";
// SSH username
String sshUsername = "jsmith";
// SSH password
String sshPassword = "secret";
// POP3 service hostname
String popHostname = "myhost.com";
// POP3 service port
int popPort = 110;
// create SSH authentication info
SshParameters sshParams = new SshParameters(sshHostname,sshUsername,sshPassword);
// create new tunnel to specified POP3 server hostname and POP3 service port
IpClientSsh tunnel = new IpClientSsh(sshParams,popHostname,popPort);
// establish tunnel
tunnel.connect();
See also