jsch 0.1.55 throws java.io.IOException: End of IO Stream Read

Viewed 828

We have been using jsch-0.1.53.jar to fetch files via SFTP daily, but after running for several years it quit working now. I assume the server administrator might have upgraded the server software.

The relevant piece of code (JAVA 1.7) contains no surprises:

            Hashtable<String, String> config = new Hashtable<String, String>();
            config.put("StrictHostKeyChecking", "no");
            sftpSession = jsch.getSession(user, host, port);
            sftpSession.setConfig(config);
            sftpSession.setPassword(password);
            sftpSession.connect();
            sftpChannel = (ChannelSftp) sftpSession.openChannel("sftp");
            sftpChannel.connect();

The last line throws "java.io.IOException: End of IO Stream Read" so I guess the server closes the connection.

I upgraded to jsch 0.1.55 (although the logging below claims it's 0.1.54) but this doesn't change anything.

The log output from jsch looks like:

*** Connecting to XXXXXXX.XXX.XX port 22
*** Connection established
*** Remote version string: SSH-2.0-7.9.0.0_openssh Globalscape
*** Local version string: SSH-2.0-JSCH-0.1.54
*** CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
*** aes256-ctr is not available.
*** aes192-ctr is not available.
*** aes256-cbc is not available.
*** aes192-cbc is not available.
*** CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
*** diffie-hellman-group14-sha1 is not available.
*** CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
*** SSH_MSG_KEXINIT sent
*** SSH_MSG_KEXINIT received
*** kex: server: diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
*** kex: server: ssh-rsa
*** kex: server: 3des-cbc,aes256-cbc,aes128-cbc,aes256-ctr,aes128-ctr
*** kex: server: 3des-cbc,aes256-cbc,aes128-cbc,aes256-ctr,aes128-ctr
*** kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
*** kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
*** kex: server: zlib,none
*** kex: server: zlib,none
*** kex: server: 
*** kex: server: 
*** kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
*** kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
*** kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
*** kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
*** kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
*** kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
*** kex: client: none
*** kex: client: none
*** kex: client: 
*** kex: client: 
*** kex: server->client aes128-ctr hmac-md5 none
*** kex: client->server aes128-ctr hmac-md5 none
*** SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
*** expecting SSH_MSG_KEX_DH_GEX_GROUP
*** Disconnecting from XXXXXXX.XXX.XX port 22

I tried config.setConfig("kex", "diffie-hellman-group1-sha1"); which has been suggested in a similar question here, but for me this didn'd work with neither 0.1.53 nor 0.1.55.

The jsch example provided by jcraft for connecting to openSSH also fails with the same Exception.

I am able to connect to the server using the same user/password using WinSCP.

Is someone able to suggest a solution (probably the proper setting of properties) based on the log?

Thanks a lot for any help.

1 Answers

As I couldn't solve this issue while sticking to jsch, I rewrote our communication layer and replaced jsch by sshj, which was quite easy in our case. This might not be a feasible solution for anyone running into this or similar issues with jsch, but for us it did the trick.

Related