Home > Back-end >  SFTP connection error com. Jcraft. JSCH. JSchException: Algorithm negotiation fail
SFTP connection error com. Jcraft. JSCH. JSchException: Algorithm negotiation fail

Time:10-19


JDK version 1.6
Using the plug-in JSCH - 0.1.55. Jar
Question:
to the remote host using SFTP error com. Jcraft. JSCH. JSchException: Algorithm negotiation fail


Use SSH - VVV IP commands and remote host contrast


The above principle explain references
https://my.oschina.net/greatqing/blog/740179

Calm down, back to the abnormal Algorithm negotiation fail, its literal meaning is Algorithm negotiation fails, check the JSCH source, exception occurs in the connect phase, surf the Internet to find information (SSH protocol), found that SSH in the communication process of five stages, there is a negotiation phase is the key and the Algorithm, in this phase, the parties according to the client and the client support Algorithm, negotiate a final used Algorithm, problems should be out of here, different versions of the OpenSSH list is different, the default Algorithm cause the failure of the negotiation Algorithm, reference com. Jcraft. JSCH. JSchException: Algorithm negotiation fail

So how do you know the different versions OpenSSH default algorithm list? Refer to What 's the openssh default kexalgorithms? Through SSH - VVV serverIp command, as shown above:

Baidu all sorts of solutions to many are need to add configuration file server, still need to restart the service, the need to end with (give up the way)

Various attempts solution needs to adjust the following two steps
1, upgrade the JDK
2, adjust the connection configuration

I will JDK from jdk1.6 upgrade to 1.7 finally upgraded to 1.8, if the JDK version fails to upgrade the complains
Com. Jcraft. JSCH. JSchException: Session. Connect: Java. IO. IOException: End of IO Stream Read

Adjust the connection configuration to add configuration code
The Properties sshConfig=new Properties ();
Kex sshConfig. Put (", "" diffie-hellman group1 -- sha1, diffie-hellman group14 -- sha1, diffie-hellman group - exchange - sha1, diffie-hellman group - exchange - the sha256");
Reference: https://stackoverflow.com/questions/26424621/algorithm-negotiation-fail-ssh-in-jenkins



Complete the above two steps, you can normal connection and use SFTP upload file
  • Related