ssh版本升级导致连接失败

公司系统使用的是第三方ssh插件jsch-0.1.39.jar,之前采集正常的,但是厂家服务器ssh升级成2.0版本,然后程序就报错,异常如下:

com.jcraft.jsch.JSchException: Algorithm negotiation fail
        at com.jcraft.jsch.Session.receive_kexinit(Session.java:510)
        at com.jcraft.jsch.Session.connect(Session.java:285)
        at com.jcraft.jsch.Session.connect(Session.java:149)
        at ...........

上网搜了下,大多数是说因为版本升级后客户端和服务器之间加密的方式不一致导致的,解决办法是修改 /etc/ssh/sshd_config 或者 /usr/etc/sshd_config 文件,添加以下内容:
 KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,[email protected]

但是,服务器是厂家的,让他们修改不容易,这个办法就pass掉了

后来同事说他之前也遇到过,把插件升级下版本就好了,于是果断下载最新版本jsch-0.1.53.jar,替换上去之后果然好了

底层的东西不了解就做个笔记吧

猜你喜欢

转载自blog.csdn.net/u013456765/article/details/52192812