jsch 0.1.55 抛出 java.io.IOException:IO 流读取结束
jsch 0.1.55 throws java.io.IOException: End of IO Stream Read
我们一直在使用 jsch-0.1.53.jar 每天通过 SFTP 获取文件,但在 运行 几年后它现在停止工作了。我假设服务器管理员可能已经升级了服务器软件。
相关的一段代码(JAVA 1.7)毫无意外:
Hashtable<String, String> config = new Hashtable<String, String>();
config.put("StrictHostKeyChecking", "no");
sftpSession = jsch.getSession(user, host, port);
sftpSession.setConfig(config);
sftpSession.setPassword(password);
sftpSession.connect();
sftpChannel = (ChannelSftp) sftpSession.openChannel("sftp");
sftpChannel.connect();
最后一行抛出“java.io.IOException: End of IO Stream Read”所以我猜服务器关闭了连接。
我升级到 jsch 0.1.55(虽然下面的日志声称它是 0.1.54)但这并没有改变任何东西。
jsch 的日志输出如下所示:
*** Connecting to XXXXXXX.XXX.XX port 22
*** Connection established
*** Remote version string: SSH-2.0-7.9.0.0_openssh Globalscape
*** Local version string: SSH-2.0-JSCH-0.1.54
*** CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
*** aes256-ctr is not available.
*** aes192-ctr is not available.
*** aes256-cbc is not available.
*** aes192-cbc is not available.
*** CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
*** diffie-hellman-group14-sha1 is not available.
*** CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
*** SSH_MSG_KEXINIT sent
*** SSH_MSG_KEXINIT received
*** kex: server: diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
*** kex: server: ssh-rsa
*** kex: server: 3des-cbc,aes256-cbc,aes128-cbc,aes256-ctr,aes128-ctr
*** kex: server: 3des-cbc,aes256-cbc,aes128-cbc,aes256-ctr,aes128-ctr
*** kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
*** kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
*** kex: server: zlib,none
*** kex: server: zlib,none
*** kex: server:
*** kex: server:
*** kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
*** kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
*** kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
*** kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
*** kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
*** kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
*** kex: client: none
*** kex: client: none
*** kex: client:
*** kex: client:
*** kex: server->client aes128-ctr hmac-md5 none
*** kex: client->server aes128-ctr hmac-md5 none
*** SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
*** expecting SSH_MSG_KEX_DH_GEX_GROUP
*** Disconnecting from XXXXXXX.XXX.XX port 22
我试过了
config.setConfig("kex", "diffie-hellman-group1-sha1");
这已在此处的类似问题中提出,但对我而言,这不适用于 0.1.53 和 0.1.55。
jcraft 提供的用于连接到 openSSH 的 jsch 示例也失败并出现相同的异常。
我可以使用相同的 user/password 使用 WinSCP 连接到服务器。
是否有人能够根据日志提出解决方案(可能是正确的属性设置)?
非常感谢您的帮助。
由于我坚持使用 jsch 无法解决这个问题,所以我重写了我们的通信层并将 jsch 替换为 sshj,这在我们的案例中非常容易。
对于任何 运行 解决此问题或与 jsch 类似的问题的人来说,这可能不是一个可行的解决方案,但对我们来说它成功了。
我们一直在使用 jsch-0.1.53.jar 每天通过 SFTP 获取文件,但在 运行 几年后它现在停止工作了。我假设服务器管理员可能已经升级了服务器软件。
相关的一段代码(JAVA 1.7)毫无意外:
Hashtable<String, String> config = new Hashtable<String, String>();
config.put("StrictHostKeyChecking", "no");
sftpSession = jsch.getSession(user, host, port);
sftpSession.setConfig(config);
sftpSession.setPassword(password);
sftpSession.connect();
sftpChannel = (ChannelSftp) sftpSession.openChannel("sftp");
sftpChannel.connect();
最后一行抛出“java.io.IOException: End of IO Stream Read”所以我猜服务器关闭了连接。
我升级到 jsch 0.1.55(虽然下面的日志声称它是 0.1.54)但这并没有改变任何东西。
jsch 的日志输出如下所示:
*** Connecting to XXXXXXX.XXX.XX port 22
*** Connection established
*** Remote version string: SSH-2.0-7.9.0.0_openssh Globalscape
*** Local version string: SSH-2.0-JSCH-0.1.54
*** CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
*** aes256-ctr is not available.
*** aes192-ctr is not available.
*** aes256-cbc is not available.
*** aes192-cbc is not available.
*** CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
*** diffie-hellman-group14-sha1 is not available.
*** CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
*** SSH_MSG_KEXINIT sent
*** SSH_MSG_KEXINIT received
*** kex: server: diffie-hellman-group16-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1
*** kex: server: ssh-rsa
*** kex: server: 3des-cbc,aes256-cbc,aes128-cbc,aes256-ctr,aes128-ctr
*** kex: server: 3des-cbc,aes256-cbc,aes128-cbc,aes256-ctr,aes128-ctr
*** kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
*** kex: server: hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
*** kex: server: zlib,none
*** kex: server: zlib,none
*** kex: server:
*** kex: server:
*** kex: client: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
*** kex: client: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
*** kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
*** kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
*** kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
*** kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
*** kex: client: none
*** kex: client: none
*** kex: client:
*** kex: client:
*** kex: server->client aes128-ctr hmac-md5 none
*** kex: client->server aes128-ctr hmac-md5 none
*** SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
*** expecting SSH_MSG_KEX_DH_GEX_GROUP
*** Disconnecting from XXXXXXX.XXX.XX port 22
我试过了 config.setConfig("kex", "diffie-hellman-group1-sha1"); 这已在此处的类似问题中提出,但对我而言,这不适用于 0.1.53 和 0.1.55。
jcraft 提供的用于连接到 openSSH 的 jsch 示例也失败并出现相同的异常。
我可以使用相同的 user/password 使用 WinSCP 连接到服务器。
是否有人能够根据日志提出解决方案(可能是正确的属性设置)?
非常感谢您的帮助。
由于我坚持使用 jsch 无法解决这个问题,所以我重写了我们的通信层并将 jsch 替换为 sshj,这在我们的案例中非常容易。 对于任何 运行 解决此问题或与 jsch 类似的问题的人来说,这可能不是一个可行的解决方案,但对我们来说它成功了。