Why SshTransportClient can connect to SSH at port 22 but Client cannot?

90 views
Skip to first unread message

Carl Roberts

unread,
Apr 12, 2012, 2:42:15 PM4/12/12
to NetconfX
Hi,

I am using the examples from the PDF doc and I have noticed that when
I use SshTransportClient class, client.setup(properties); works fine.

However, when I use the Client class and pass in
properties.put("protocol", "ssh"); and then call
client.setup(properties); it fails with this error:

java.lang.RuntimeException: An error occured in the transport layer:
Failed to connect to SSH server: 192.168.71.128 at port:22

A.V.

unread,
Apr 12, 2012, 3:48:19 PM4/12/12
to netc...@googlegroups.com
Hello,
  Not sure why you are seeing this problem - Client.setup(properties) just calls SshTransportClient.setup(properties). The same property values are used in both cases. Could you provide me with more information about your code?
   There is a file in the test folder called ClientTest which provides samples on how to use the Client class - that might be helpful.
    One possibility is that your target port is not 22 - often the SSH port for netconf is configured to be something else (like 830).
A.V.

Carl Roberts

unread,
Apr 12, 2012, 9:07:10 PM4/12/12
to NetconfX
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)

Carl Roberts

unread,
Apr 12, 2012, 9:07:58 PM4/12/12
to NetconfX
When I try this code:

public class NetConfXTest {

/**
* @param args the command line arguments
*/
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:


debug:
Setting up SSH transport client ..
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)

Reply all
Reply to author
Forward
0 new messages