Java JSCHEException:算法协商失败
我试图使用JSch(0.1.44-1)通过ssh连接到远程sftp服务器,但在“session.connect();”期间,我遇到了以下异常:Java JSCHEException:算法协商失败,java,encryption,ssh,sftp,jsch,Java,Encryption,Ssh,Sftp,Jsch,我试图使用JSch(0.1.44-1)通过ssh连接到远程sftp服务器,但在“session.connect();”期间,我遇到了以下异常: com.jcraft.jsch.JSchException: Algorithm negotiation fail at com.jcraft.jsch.Session.receive_kexinit(Session.java:529) at com.jcraft.jsch.Session.connect(Session.java:291) at c
com.jcraft.jsch.JSchException: Algorithm negotiation fail at
com.jcraft.jsch.Session.receive_kexinit(Session.java:529) at
com.jcraft.jsch.Session.connect(Session.java:291) at com.jcraft.jsch.Session.connect(Session.java:154)
...
来自JSch的日志:
INFO: Connecting to xx.xx.xx.xxport 22
INFO: Connection established
INFO: Remote version string: SSH-2.0-WeOnlyDo 2.0.6
INFO: Local version string: SSH-2.0-JSCH-0.1.44
INFO: CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
INFO: aes256-ctr is not available.
INFO: aes192-ctr is not available.
INFO: aes256-cbc is not available.
INFO: aes192-cbc is not available.
INFO: arcfour256 is not available.
INFO: SSH_MSG_KEXINIT sent
INFO: SSH_MSG_KEXINIT received
INFO: Disconnecting from xx.xx.xx.xx port 22
我能够使用linux sftp命令登录到远程服务器。我试图在互联网上找到任何线索,但失败了
linux sftp命令的调试输出:
OpenSSH_5.5p1-DAM_1.2, OpenSSL 0.9.8r 8 Feb 201
debug1: Reading configuration data /etc/DAM/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for *.*
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /**/spv_id_rsa.key type -1
debug1: identity file /**/spv_id_rsa.key-cert type -1
debug1: Remote protocol version 2.0, remote software version WeOnlyDo 2.0.6
debug1: no match: WeOnlyDo 2.0.6
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.5p1-DAM_1.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes256-cbc hmac-md5 none
debug1: kex: client->server aes256-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'xx.xx.xx.xx' is known and matches the RSA host key.
debug1: Found key in ~/.ssh/known_hosts:8
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /**/spv_id_rsa.key
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending subsystem: sftp
Connected to xx.xx.xx.xx.
sftp>
SSH客户机和服务器可以在几个地方尝试并商定一个通用的实现。我知道的两个是加密和压缩。服务器和客户端生成一个可用选项列表,然后选择两个列表中的最佳可用选项 如果列表中没有可接受的选项,那么它将失败,并出现您得到的错误。我从这里的调试输出中猜测,但看起来唯一的加密服务器选项是“aes256 cbc hmac-md5 none” JSch不执行hmac-md5,aes256 cbc由于您的Java策略文件而被禁用。你可以尝试的两件事是
如果您可以访问服务器(请相信我aes128 cbc有很多加密功能),那么第一种方法非常理想,但第二种方法非常简单,可以快速测试理论。SSH客户端和服务器可以在几个地方尝试并商定一种通用实现。我知道的两个是加密和压缩。服务器和客户端生成一个可用选项列表,然后选择两个列表中的最佳可用选项 如果列表中没有可接受的选项,那么它将失败,并出现您得到的错误。我从这里的调试输出中猜测,但看起来唯一的加密服务器选项是“aes256 cbc hmac-md5 none” JSch不执行hmac-md5,aes256 cbc由于您的Java策略文件而被禁用。你可以尝试的两件事是
如果您可以访问服务器,第一种方法非常理想(相信我aes128 cbc有很多加密功能),但第二种方法非常容易,可以快速测试理论。FWIW,我在JSch 0.1.50下也收到了同样的错误消息。升级到0.1.52解决了问题。FWIW,我在JSch 0.1.50下收到了相同的错误消息。升级到0.1.52解决了这个问题。我也遇到了同样的问题,在Windows上运行Netbeans 8.0和JRE 1.7
我刚从安装了JRE 1.8(请注意,它被称为
Version 8
,但安装它时它是Version 1.8),并且它修复了它。我也遇到了同样的问题,在Windows上运行Netbeans 8.0和JRE 1.7
我刚从安装了JRE 1.8(请注意,它被称为
Version 8
,但安装它时它是Version 1.8),并且它修复了它。最后,一个不需要对服务器进行任何更改的解决方案:
对Webstorm使用相同的解决方案最后,一个无需对服务器进行任何更改即可工作的解决方案:
对Webstorm使用相同的解决方案问题在于您使用的JSCH jar版本 更新到最新的jar 我也遇到了同样的错误,这个解决方案奏效了 您可以从下载最新的jar
问题在于您使用的JSCH jar版本 更新到最新的jar 我也遇到了同样的错误,这个解决方案奏效了 您可以从下载最新的jar 添加kexalgoriths diffie-hellman-group1-sha1,diffie-hellman-GroupExchange sha1至 服务器上的sshd_配置 这是可行的,但请确保重新启动sshd: sudo服务sshd重启 添加kexalgoriths diffie-hellman-group1-sha1,diffie-hellman-GroupExchange sha1至 服务器上的sshd_配置 这是可行的,但请确保重新启动sshd:
sudo service sshd restart将算法添加到接收服务器(您正在连接的服务器)的完整步骤。我假设这是一个Linux服务器
sudo /etc/ssh/sshd_config
将其添加到文件中(可以在末尾):
然后重新启动SSH服务器:
sudo service sshd restart
将算法添加到接收服务器(您正在连接的服务器)的完整步骤。我假设这是一个Linux服务器
sudo /etc/ssh/sshd_config
将其添加到文件中(可以在末尾):
然后重新启动SSH服务器:
sudo service sshd restart
确保您使用的是最新版本的JSch。在使用JSch 0.1.31并尝试连接到RedHat 5服务器时,我遇到了完全相同的问题。更新到最新版本解决了问题。确保您使用的是最新版本的JSch。在使用JSch 0.1.31并尝试连接到RedHat 5服务器时,我遇到了完全相同的问题。更新至solv的最新版本