Cannot log into to SSH2 port 22 no matter what I try

337 views
Skip to first unread message

Carl Roberts

unread,
Apr 13, 2012, 9:16:44 AM4/13/12
to NetconfX
Hi,

I have tried using the latest puttygen.exe tool to generate a 2048 RSA
public / private key pair. This is what I have done:

1 - Generate a 2048 RSA public / private key in puttygen.exe.
2 - Save the public and private key.
3 - Export the private key as OpenSSH format from puttygen.exe.
4 - Added the content of the public key to the /etc/.ssh/
authorized_keys file on the RHEL5 box, making sure it is in the
correct format and in one single line.
5 - Configured putty.exe on a Windows box to use the private key.
6 - Logged through putty.exe from the Windows box to the Linux box
using the private key and SSH2 - This works!
7 - Wrote a Java class with a main method to pass in the username and
certificate options, making sure to provide the full path to the
OpenSSH format private key file.

Here is the code:

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", "120000");
props.put("port", "22");
props.put("username", "oracle");
//props.put("password", "oracle");
//props.put("passphrase", "foo");
props.put("certificate", "c:/dev/tools/puttygen/ssh_key.pem");
client.setup(props);
System.out.println("SSH transport client setup complete.");
//Capabilities caps = client.getDeviceCapabilities();
//System.out.println(caps.toString());
client.shutdown();
}

connection fails from the program

Carl Roberts

unread,
Apr 13, 2012, 9:24:00 AM4/13/12
to NetconfX
Here is the output just in case:

Setting up SSH transport client ..
Apr 13, 2012 9:22:38 AM com.centeredlogic.util.CLThread run
INFO: Starting thread - NotificationStreamPinger-192.168.56.101;
transferring control to runnable ..
Apr 13, 2012 9:23:06 AM
com.centeredlogic.net.netconf.transport.ssh.SshConnection <init>
INFO: Connected to: 192.168.56.101:22 using Key authentication
Apr 13, 2012 9:23:06 AM
com.centeredlogic.net.netconf.transport.ssh.SshConnection
establishSession
SEVERE: Error connecting to device SSH server: The subsystem request
failed.
Apr 13, 2012 9:23:06 AM
com.centeredlogic.net.netconf.transport.ssh.SshTransportClient
obtainConnection
SEVERE: Exception acquiring SSH connection
java.lang.RuntimeException: Failed to connect to SSH server:
192.168.56.101 at port:22
at
com.centeredlogic.net.netconf.transport.ssh.SshConnection.establishSession(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 13, 2012 9:23:06 AM
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 connect to SSH server: 192.168.56.101 at port:22
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)

Exception in thread "main" java.lang.RuntimeException: An error
occured in the transport layer: An error occured in the transport
layer: Failed to connect to SSH server: 192.168.56.101 at port:22
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)
Java Result: 1
BUILD SUCCESSFUL (total time: 36 seconds)

On Apr 13, 9:16 am, Carl Roberts <carl.roberts.zap...@gmail.com>
wrote:

Carl Roberts

unread,
Apr 13, 2012, 9:27:10 AM4/13/12
to NetconfX
I can provide the key files if you want to try it.

Carl Roberts

unread,
Apr 13, 2012, 9:51:02 AM4/13/12
to NetconfX

OK,

I think I am now getting somewhere.

I switched to root on the Linux box and tailed the /var/log/secure
file and I see this after attempting to run the Java code:


Apr 13 09:47:15 localhost sshd[8951]: Accepted publickey for oracle
from 192.168.56.1 port 51932 ssh2
Apr 13 09:47:15 localhost sshd[8951]: pam_unix(sshd:session): session
opened for user oracle by (uid=0)
Apr 13 09:47:15 localhost sshd[8957]: subsystem request for netconf
Apr 13 09:47:15 localhost sshd[8957]: subsystem request for netconf
failed, subsystem not found
Apr 13 09:47:15 localhost sshd[8957]: Received disconnect from
192.168.56.1: 11: Closed due to user request.
Apr 13 09:47:15 localhost sshd[8951]: pam_unix(sshd:session): session
closed for user oracle


It seems to me that I am connecting to via SSH now but the underlying
problem now is that there is no NETCONF server now - would you agree?

If so, then what do you suggest I try next - is there an easy tutorial
somewhere that will show me how to setup a NETCONF server so that I
can test your API?
Reply all
Reply to author
Forward
0 new messages