0

I am using jsch-0.1.51.jar for sftp connection in my program and it was working fine for last 1 year but suddenly program started throwing error :

Algorithm negotiation fail. Below code: 
    =========================================
            jsch.addIdentity(sftpIdentityFilePath);
        logger.info("*****************Getting SFTP Connection******************");
        session = jsch.getSession(sftpUser, sftpHost, 2222);
        System.out.println("crossed seesion initialize");
        session.setConfig("StrictHostKeyChecking", "no");
        System.out.println("crossed seesion config");
        session.connect();
        System.out.println("crossed seesion connect");
        channel= session.openChannel("sftp");
        System.out.println("sftp server connected");
        logger.info("SFTP server connected");
        channel.connect();
        logger.info("*****************SFTP Connected******************");


    ==============================================================    

After finding the issue I have used a updated jar to jsch-0.1.54.jar. But it's throwing a different exception

2018-04-28 18:17:51 ERROR FileCopyMain:978 - 
Session.connect: java.io.IOException: End of IO Stream Read

Also in both this cases when I am trying to run this program from Eclipse IDE then it's working fine. But when I am creating the jar file of this Java code then I am getting these issue.

Context of this SFTP connection code: I am connecting a server using private key to download files to my local

Can some body please help me out with this?

dave_thompson_085
  • 34,712
  • 6
  • 50
  • 70
DAWN
  • 1
  • 1
  • 3
  • Can you post the relevant part of the code where you're using `jsch`? – craigcaulfield Apr 29 '18 at 01:03
  • I have edit my code section is question. I am using jsch for sftp connection. I am getting this above error while trying to connect this session. above session.connect(); line is throwing exception. – DAWN Apr 29 '18 at 01:27
  • Context of this SFTP connection code: I am connecting a server using private key to download files to my local – DAWN Apr 29 '18 at 01:28

1 Answers1

1

Algorithm negotiation fail.

This means that the client and server side could not agree on the encryption algorithm to be used to keep the SSH connection secure. When that happens, the server side will close the connection, leading to the IOException that you see.

The most likely explanation is that either the client side SSH implementation is out of date, or the server-side SSH implementation is out of date. There should be some clues in the jcsh "DEBUG" logging; see JSch logger - where can I configure the level. If that fails, look at the logs on the server side.

The solution will depend on what you find.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Jsch logging is a good idea; JSSE does not apply because SSH is a completely different protocol from SSL/TLS and _is_ implemented entirely in Jsch not using JSSE or any other protocol provider. (It does use primitives like ciphers and hashes from whatever JCA providers you have.) Among other differences, SSH negotiates several separate algorithms while SSL/TLS (except for draft 1.3 not yet implemented) negotiates a single ciphersuite that contains the algorithms. – dave_thompson_085 Apr 29 '18 at 06:02