public class SSHConnection
extends java.lang.Object
NetconfSession
intends to use SSH for its transport.
Example:
SSHConnection ssh = new SSHConnection("127.0.0.1", 2023);
ssh.authenticateWithPassword("ola", "secret");
SSHSession tr = new SSHSession(ssh);
NetconfSession dev1 = new NetconfSession(tr);
| Constructor and Description |
|---|
SSHConnection(java.lang.String host)
By default we connect to the IANA registered port for NETCONF which is
830
|
SSHConnection(java.lang.String host,
int port)
This method establishes an SSH connection to a host, once the connection
is established it must be authenticated.
|
SSHConnection(java.lang.String host,
int port,
int connectTimeout)
This method establishes an SSH connection to a host, once the connection
is established it must be authenticated.
|
SSHConnection(java.lang.String host,
int port,
int connectTimeout,
int kexTimeout)
This method establishes an SSH connection to a host, once the connection
is established it must be authenticated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
authenticateWithPassword(java.lang.String user,
java.lang.String password)
Authenticate with regular username pass.
|
void |
authenticateWithPublicKey(java.lang.String user,
char[] pemPrivateKey,
java.lang.String pass)
Authenticate with a private key.
|
void |
authenticateWithPublicKeyFile(java.lang.String user,
java.io.File pemFile,
java.lang.String password)
Authenticate with the name of a file containing the private key See
ganymed docs for full explanation, use null for password if the key
doesn't have a passphrase.
|
void |
close()
Closes the SSH session/connection.
|
Connection |
getGanymedConnection()
This is required if wish to have access to the ganymed connection object
outside of this package.
|
public SSHConnection(java.lang.String host)
throws java.io.IOException,
JNCException
host - Host or IP address to connect tojava.io.IOExceptionJNCExceptionpublic SSHConnection(java.lang.String host,
int port)
throws java.io.IOException,
JNCException
host - Host name.port - Port number to connect to.java.io.IOExceptionJNCExceptionpublic SSHConnection(java.lang.String host,
int port,
int connectTimeout)
throws java.io.IOException,
JNCException
host - Host name.port - Port number to connect to.connectTimeout - java.io.IOExceptionJNCExceptionpublic SSHConnection(java.lang.String host,
int port,
int connectTimeout,
int kexTimeout)
throws java.io.IOException,
JNCException
host - Host name.port - Port number to connect to.connectTimeout - Connection timeout timer. Connect the underlying
TCP socket to the server with the given timeout value
(non-negative, in milliseconds). Zero means no timeout.kexTimeout - Key exchange timeout timer. Timeout for complete
connection establishment (non-negative, in milliseconds).
Zero means no timeout. The timeout counts until the first
key-exchange round has finished.java.io.IOException - In case of a timeout (either connectTimeout or
kexTimeout) a SocketTimeoutException is thrown.
An exception may also be thrown if the connection was
already successfully connected (no matter if the connection
broke in the mean time) and you invoke
connect() again without having called
close() first.
JNCExceptionpublic Connection getGanymedConnection()
public void authenticateWithPassword(java.lang.String user,
java.lang.String password)
throws java.io.IOException,
JNCException
user - User name.password - Password.java.io.IOExceptionJNCExceptionpublic void authenticateWithPublicKeyFile(java.lang.String user,
java.io.File pemFile,
java.lang.String password)
throws java.io.IOException,
JNCException
user - User name.pemFile - Fila name.password - Password.java.io.IOExceptionJNCExceptionpublic void authenticateWithPublicKey(java.lang.String user,
char[] pemPrivateKey,
java.lang.String pass)
throws java.io.IOException,
JNCException
user - User name.pemPrivateKey - Private key.pass - Passphrase.java.io.IOExceptionJNCExceptionpublic void close()