当前位置: 首页 > 面试题库 >

JSch 0.1.53 session.connect()抛出“ IO流读取结束”

逑衡
2023-03-14
问题内容

我下载了新的JSch
0.1.53库,
并且JSch(sftp)下载任务不再起作用。此版本因session.connect()函数抛出错误而失败Session.connect: java.io.IOException: End of IO Stream Read

我的旧jsch.jar(2011-10-06)在同一主机上运行正常,也许我缺少新的配置道具?

Session session=null;
ChannelSftp channel=null;
try {
    JSch.setLogger(SSHUtil.createJschLogger());

    JSch jsch=new JSch();
    session=jsch.getSession("myuser", "11.22.33.44", 22);
    session.setConfig("StrictHostKeyChecking", "no"); 
    session.setPassword("mypwd");
    session.connect(2000); // <-- FAILS HERE
    channel = (ChannelSftp)session.openChannel("sftp");
    channel.connect(2000);
    ...

这是一个广泛的JSch日志记录,指示发生了什么。

INFO : Connecting to 11.22.33.44 port 22
INFO : Connection established
INFO : Remote version string: SSH-2.0-OpenSSH_6.6.1
INFO : Local version string: SSH-2.0-JSCH-0.1.53
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 : CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
INFO : diffie-hellman-group14-sha1 is not available.
INFO : ecdh-sha2-nistp256 is not available.
INFO : ecdh-sha2-nistp384 is not available.
INFO : ecdh-sha2-nistp521 is not available.
INFO : CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
INFO : ecdsa-sha2-nistp256 is not available.
INFO : ecdsa-sha2-nistp384 is not available.
INFO : ecdsa-sha2-nistp521 is not available.
INFO : SSH_MSG_KEXINIT sent
INFO : SSH_MSG_KEXINIT received
INFO : kex: server: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
INFO : kex: server: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
INFO : kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
INFO : kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
INFO : kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
INFO : kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
INFO : kex: server: none,zlib@openssh.com
INFO : kex: server: none,zlib@openssh.com
INFO : kex: server:
INFO : kex: server:
INFO : kex: client: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
INFO : kex: client: ssh-rsa,ssh-dss
INFO : kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
INFO : kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
INFO : kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
INFO : kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
INFO : kex: client: none
INFO : kex: client: none
INFO : kex: client:
INFO : kex: client:
INFO : kex: server->client aes128-ctr hmac-md5 none
INFO : kex: client->server aes128-ctr hmac-md5 none
INFO : SSH_MSG_KEX_DH_GEX_REQUEST(1024<1024<1024) sent
INFO : expecting SSH_MSG_KEX_DH_GEX_GROUP
INFO : Disconnecting from 11.22.33.44 port 22
Exception in thread "main" com.jcraft.jsch.JSchException: Session.connect: java.io.IOException: End of IO Stream Read
        at com.jcraft.jsch.Session.connect(Session.java:558)
        at com.jcraft.jsch.Session.connect(Session.java:183)
        at my.test.DownloadSFTP.main(DownloadSFTP.java:37)
Caused by: java.io.IOException: End of IO Stream Read
        at com.jcraft.jsch.IO.getByte(IO.java:84)
        at com.jcraft.jsch.Session.read(Session.java:918)
        at com.jcraft.jsch.Session.connect(Session.java:323)

我还有一个非常旧的Jsch.jar(2011-10-06),其中下载任务正常运行,这是一个日志。我要升级的原因是文件传输速度非常慢。新版本应该做得更好,我已阅读。

INFO : Connecting to 11.22.33.44 port 22
INFO : Connection established
INFO : Remote version string: SSH-2.0-OpenSSH_6.6.1
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 : kex: server->client aes128-ctr hmac-md5 none
INFO : kex: client->server aes128-ctr hmac-md5 none
INFO : SSH_MSG_KEXDH_INIT sent
INFO : expecting SSH_MSG_KEXDH_REPLY
INFO : ssh_rsa_verify: signature true
WARN : Permanently added '11.22.33.44' (RSA) to the list of known hosts.
INFO : SSH_MSG_NEWKEYS sent
INFO : SSH_MSG_NEWKEYS received
INFO : SSH_MSG_SERVICE_REQUEST sent
INFO : SSH_MSG_SERVICE_ACCEPT received
INFO : Authentications that can continue: publickey,keyboard-interactive,password
INFO : Next authentication method: publickey
INFO : Authentications that can continue: keyboard-interactive,password
INFO : Next authentication method: keyboard-interactive
INFO : Authentication succeeded (keyboard-interactive).
INFO : Disconnecting from 11.22.33.44 port 22
INFO : Caught an exception, leaving main loop due to socket closed

编辑
我有一个想法可以在Maven存储库中回退发行版,实际上,这是一个非常新的发行版,无法正常工作。先前的jsch-0.1.52.jar版本可以正常工作。我尝试与图书馆开发人员联系。

这是来自运行中的0.1.52版本的日志。

INFO : Connecting to 11.22.33.44 port 22
INFO : Connection established
INFO : Remote version string: SSH-2.0-OpenSSH_6.6.1
INFO : Local version string: SSH-2.0-JSCH-0.1.52
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 : CheckKexes: diffie-hellman-group14-sha1,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521
INFO : diffie-hellman-group14-sha1 is not available.
INFO : ecdh-sha2-nistp256 is not available.
INFO : ecdh-sha2-nistp384 is not available.
INFO : ecdh-sha2-nistp521 is not available.
INFO : CheckSignatures: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
INFO : ecdsa-sha2-nistp256 is not available.
INFO : ecdsa-sha2-nistp384 is not available.
INFO : ecdsa-sha2-nistp521 is not available.
INFO : SSH_MSG_KEXINIT sent
INFO : SSH_MSG_KEXINIT received
INFO : kex: server: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
INFO : kex: server: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
INFO : kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
INFO : kex: server: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
INFO : kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
INFO : kex: server: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
INFO : kex: server: none,zlib@openssh.com
INFO : kex: server: none,zlib@openssh.com
INFO : kex: server:
INFO : kex: server:
INFO : kex: client: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256
INFO : kex: client: ssh-rsa,ssh-dss
INFO : kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
INFO : kex: client: aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc
INFO : kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
INFO : kex: client: hmac-md5,hmac-sha1,hmac-sha2-256,hmac-sha1-96,hmac-md5-96
INFO : kex: client: none
INFO : kex: client: none
INFO : kex: client:
INFO : kex: client:
INFO : kex: server->client aes128-ctr hmac-md5 none
INFO : kex: client->server aes128-ctr hmac-md5 none
INFO : SSH_MSG_KEXDH_INIT sent
INFO : expecting SSH_MSG_KEXDH_REPLY
INFO : ssh_rsa_verify: signature true
WARN : Permanently added '11.22.33.44' (RSA) to the list of known hosts.
INFO : SSH_MSG_NEWKEYS sent
INFO : SSH_MSG_NEWKEYS received
INFO : SSH_MSG_SERVICE_REQUEST sent
INFO : SSH_MSG_SERVICE_ACCEPT received
INFO : Authentications that can continue: publickey,keyboard-interactive,password
INFO : Next authentication method: publickey
INFO : Authentications that can continue: keyboard-interactive,password
INFO : Next authentication method: keyboard-interactive
INFO : Authentication succeeded (keyboard-interactive).

问题答案:

JSch 0.1.53支持(并且更喜欢)diffie-hellman-group-exchange- sha256KEX,服务器声称也支持KEX,因此JSch尝试使用它。

由于某种原因,服务器之后会断开您的连接。

要解决此问题,请强制JSch使用diffie-hellman-group1-sha1KEX,JSch 0.1.52更喜欢:

session.setConfig("kex", "diffie-hellman-group1-sha1");


 类似资料:
  • 我们每天都使用jsch-0.1.53.jar通过SFTP获取文件,但是运行了几年后,它现在停止工作了。我想服务器管理员可能已经升级了服务器软件。 相关代码(JAVA 1.7)不包含任何意外: 最后一行抛出“java.io.IOException:io流读取结束”,所以我想服务器会关闭连接。 我升级到了jsch 0.1.55(尽管下面的日志声称它是0.1.54),但这并没有改变任何事情。 jsch的

  • 最近我在读一张MifareClassic 1K卡。在阅读了事实之后,只有某些带有恩智浦芯片的手机才能读取这些标签,而获得这些标签中的一个,我面临着一个新的问题 我试图阅读的卡片会抛出标题中提到的错误,但只有在运行时没有逐行检查代码。这里有一些细节:起初,我从Xamarin那里取了NFCSample,并做了一些改变: 因此,如果我单步执行代码ReadBlock/ReadBlockAsync,它的工作

  • 本文向大家介绍Java基于IO流读取文件的方法,包括了Java基于IO流读取文件的方法的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了Java基于IO流读取文件的方法。分享给大家供大家参考,具体如下: 希望本文所述对大家Java程序设计有所帮助。

  • 本文向大家介绍java的IO流详细解读,包括了java的IO流详细解读的使用技巧和注意事项,需要的朋友参考一下 流,就是一系列的数据。 当不同介质之间有数据交互的时候,JAVA就使用流来实现。数据源可以是文件,还可以是数据库、网络甚至其他的程序。 比如读取文件的数据到程序中,站在程序的角度来看,就叫做输入流。 字节流(以字节的形式读取和写入数据) InputStream字节输入流同时也是抽象类,只

  • 问题内容: 我想制作一个Servlet过滤器,该过滤器将在处理和完成响应后读取响应的内容,并以XML或PDF或其他方式返回该信息。但是我不确定如何从HttpServletResponse对象中获取任何信息。我如何获得此信息? 问题答案: 将此添加到过滤器java文件。 使用以下代码: 现在,content变量具有输出流。您也可以对二进制内容执行此操作。

  • 给出以下错误: PY4JJavaError:调用O139.Load时出错。:java.lang.ClassNotFoundException:未能找到数据源:com.crealytics.spark.excel。请在http://spark.apache.org/third-party-projects.html找到包,地址为org.apache.spark.sql.execution.datas