wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Can't connect to ssh server using jsch or sshtools -- OpenSSL misconfiguration or coding error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Can Watch "Can New topic
Author

Can't connect to ssh server using jsch or sshtools -- OpenSSL misconfiguration or coding error?

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
I have written two methods for issuing an ssh command -- one using jsch version 0.1.31 and another using j2ssh-core version 0.2.9 -- and neither of them get past the connect step so I assume it's not an authentication problem since I don't even get to that step. With the code which uses the jsch library I get a JSchException: Algorithm negotiation fail, and with the code which uses the sshtools library I get an IOException: Socket is EOF. I have no clue as to what either of these exceptions indicate, and have found nothing so far using Google, amiling list archives, etc. However if I try the same ssh command at command line I have no errors. So it seems that my error is somehow related to running the Java code and not with the ssh configuration, but I'm not certain and hoping that someone reading this can guide me to a way of determining whether or not that's the case, and if so how to fix things.

When I run 'ssh -V' on both the local machine where I am running my Java codes as well as on the remote machine where I am trying to run the ssh commands I get the following result:

Sun_SSH_1.3, SSH protocols 1.5/2.0, OpenSSL 0x0090801f

Is there a way to determine whether or not this version of OpenSSL is compatible with either or both of the ssh libraries I'm using for this task?

Below are snippets of the code I have written -- I think they're OK but maybe I've done something wrong at the Java level and if so then please point it out to me:



Thanks in advance for any suggestions or ideas.

--James
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Can you set the SSH protocol to use in JSch or sshtools? Perhaps they are using SSH protocol 1.0 by default, and your server doesn't support that.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
Thanks, Rob. I don't see a way in either library to set the protocol level that the client instance should use, however both of these libraries support SSL 2.0 so I don't think that that is the issue. In any event I've resorted to a brute force approach running ssh and scp commands using Runtime.exec() in order to move on and get some work done. It's not elegant but it's working fine for now.

--James
Toufik Hamdani
Greenhorn

Joined: Nov 05, 2009
Posts: 1
I have exactly the same problems as you. I don't know how to bypass this problem. Did anyone have the same problem and find how to resolve it ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't connect to ssh server using jsch or sshtools -- OpenSSL misconfiguration or coding error?
 
Similar Threads
[Jsch] channel.connect works only sometimes
Execute a command on a remote Shell using JSCH
Invoking unix shell commands from java.
How to connect to Linux using Java code?
JSCH : dos2unix command not working