问题描述
- JSCH连接SFTP服务Algorithm negotiation fail
- JAVA环境:
java version ""1.6.0_45""
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Server VM (build 20.45-b01 mixed mode)jsch-0.1.42.jar
SFTP环境:
OpenSSH_6.7p1 OpenSSL 1.0.1j 15 Oct 2014。现象就是应用程序客户端始终SFTP连接不了服务端,导致很多功能不能使用。
而在一些旧版本的OpenSSL机器上,如0.9.8e版本上是没有问题的,只要一升级OpenSSL就会导致该问题。尝试思路:
1. JSCH版本过低,不支持最新版本OpenSSL导致的。
升级到JSCH 0.1.51版本后依然不行。- JSCH不支持ECDSA算法,是无法使用最新OpenSSL的。
为JSCH添加支持ECDSA算法的插件--->未测试。
有没有哪位大神指明一下? - 使用SSH调试模式连接:
debug1:no match JSCH-0.1.51
...
debug1:list_hostkey_types:ssh-rsa ssh-dssecdsa-sha2-nistp256ssh-ed25519[preauth]
...
debug1:kex:client->server aes128-ctr hmac-sha1 none [preauth]
debug1:kex:server->client aes128-ctr hmac-sha1 none [preauth]
debug1:Unable to negotiate a key exchange method [preauth]
...
然后尝试在sshd_config中添加了
Ciphers aes128-ctraes192-ctraes256-ctr
还是不行。求哪位大神指教一下,给个思路。
- JSCH不支持ECDSA算法,是无法使用最新OpenSSL的。
解决方案
After upgrading OpenSSL and OpenSSH before re-start ssh service:
Please add parameters in configure file < /etc/ssh/sshd_config > and < /usr/etc/sshd_config > as below:
KexAlgorithms diffie-hellman-group1-sha1diffie-hellman-group14-sha1diffie-hellman-group-exchange-sha1diffie-hellman-group-exchange-sha256ecdh-sha2-nistp256ecdh-sha2-nistp384ecdh-sha2-nistp521diffie-hellman-group1-sha1curve25519-sha256@libssh.org
because of algorithm negotiation fail occurred by OpenSSH and JSCH.
key exchange failure between JSCH and OpenSSH it’s common issue for all code users.
JSCH support Key exchange algorithms: diffie-hellman-group1-sha1和diffie-hellman-group-exchange-sha1
But these algorithms are not listed by OpenSSH_6.7p1 Key exchange algorithms list.
So we need to specify key exchange algorithms in SSH configure files.
解决方案二:
你好,请问你的这个问题解决了吗?我现在也遇到了这个问题。主机ssh升级到6.7后,我们使用jsch jar包ssh连接不上报Algorithm negotiation fail。
解决方案三:
请问你的问题解决了吗?我也遇到了这个问题,请给我指点一下吧?