I have tried this code after setting up a private certificate and it
does not work:
public static void main(String[] args) {
System.out.println("Setting up SSH transport client .. ");
Client client = new Client();
Properties props = new Properties();
props.put("protocol", "ssh");
props.put("host", "192.168.56.101");
props.put("socketTimeout", "30000");
props.put("port", "22");
//props.put("username", "oracle");
//props.put("password", "oracle");
props.put("certificate", "c:/dev/tools/puttygen/ssh_key.ppk");
// You could use a certificate with a passphrase instead of a
password
client.setup(props);
System.out.println("SSH transport client setup complete.");
Capabilities caps = client.getDeviceCapabilities();
System.out.println(caps.toString());
client.shutdown();
}
I get this:
Apr 12, 2012 9:02:46 PM com.centeredlogic.util.CLThread run
INFO: Starting thread - NotificationStreamPinger-192.168.56.101;
transferring control to runnable ..
Apr 12, 2012 9:03:14 PM com.centeredlogic.net.ssh.SshConnection
authenticateWithKey
SEVERE: Error authenticating with key: Publickey authentication
failed.
Apr 12, 2012 9:03:14 PM com.centeredlogic.net.ssh.SshConnection
authenticateWithKey
SEVERE: Failed to authenticate user: admin on host: 192.168.56.101
using certificates
Apr 12, 2012 9:03:14 PM com.centeredlogic.net.ssh.SshConnection
authenticateWithPassword
SEVERE: Error authenticating with password: password argument is null
Apr 12, 2012 9:03:14 PM com.centeredlogic.net.ssh.SshConnection
authenticateWithPassword
SEVERE: Failed to authenticate user: admin on host: 192.168.56.101
Apr 12, 2012 9:03:14 PM
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient
obtainConnection
SEVERE: Exception acquiring SSH connection
java.lang.RuntimeException: Failed to authenticate user: admin on
host: 192.168.56.101
at
com.centeredlogic.net.ssh.SshConnection.authenticateWithPassword(Unknown
Source)
at
com.centeredlogic.net.ssh.SshConnection.connectAndAuthenticate(Unknown
Source)
at
com.centeredlogic.net.netconf.transport.ssh.SshConnection.<init>(Unknown
Source)
at
com.centeredlogic.net.netconf.transport.ssh.SyncSshConnection.<init>(Unknown
Source)
at
com.centeredlogic.net.netconf.transport.ssh.SshConnectionPoolHandler.makeObject(Unknown
Source)
at
org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:
840)
at
com.centeredlogic.net.netconf.transport.ssh.SshConnectionPoolHandler.getConnection(Unknown
Source)
at
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient.obtainConnection(Unknown
Source)
at
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient.send(Unknown
Source)
at com.centeredlogic.net.netconf.Client.sendRaw(Unknown Source)
at com.centeredlogic.net.netconf.Client.send(Unknown Source)
at com.centeredlogic.net.netconf.Client.loadDeviceCaps(Unknown
Source)
at com.centeredlogic.net.netconf.Client.setup(Unknown Source)
at netconfxtest.NetConfXTest.main(NetConfXTest.java:32)
Apr 12, 2012 9:03:14 PM
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient send
SEVERE: Exception during NETCONF rpc send
java.lang.RuntimeException: An error occured in the transport layer:
Failed to authenticate user: admin on host: 192.168.56.101
at
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient.obtainConnection(Unknown
Source)
at
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient.send(Unknown
Source)
at com.centeredlogic.net.netconf.Client.sendRaw(Unknown Source)
at com.centeredlogic.net.netconf.Client.send(Unknown Source)
at com.centeredlogic.net.netconf.Client.loadDeviceCaps(Unknown
Source)
at com.centeredlogic.net.netconf.Client.setup(Unknown Source)
at netconfxtest.NetConfXTest.main(NetConfXTest.java:32)