Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JSch 0.1.53 session.connect()抛出;IO流读取结束";_Java_Sftp_Jsch - Fatal编程技术网

Java JSch 0.1.53 session.connect()抛出;IO流读取结束";

Java JSch 0.1.53 session.connect()抛出;IO流读取结束";,java,sftp,jsch,Java,Sftp,Jsch,我下载了一个新的JSch(sftp)下载任务,它不再工作。此版本在session.connect()函数抛出错误时失败。connect:java.io.IOException:io流读取结束 我的旧jsch.jar(2011-10-06)在同一台主机上运行良好,也许我缺少了一个新的配置道具 Session session=null; ChannelSftp channel=null; try { JSch.setLogger(SSHUtil.createJschLogger());

我下载了一个新的JSch(sftp)下载任务,它不再工作。此版本在
session.connect()
函数抛出错误时失败。connect:java.io.IOException:io流读取结束

我的旧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-0.1.52.jar版本运行良好。我试着联系图书馆的开发人员

这是正在运行的0.1.52版本的日志

INFO:连接到11.22.33.44端口22
信息:已建立连接
信息:远程版本字符串:SSH-2.0-OpenSSH_6.6.1
信息:本地版本字符串:SSH-2.0-JSCH-0.1.52
信息:校验密码:aes256 ctr、aes192 ctr、aes128 ctr、aes256 cbc、aes192 cbc、aes128 cbc、3des ctr、arcfour、arcfour128、arcfour256
信息:aes256 ctr不可用。
信息:aes192 ctr不可用。
信息:aes256 cbc不可用。
信息:aes192 cbc不可用。
信息:复选框:diffie-hellman-group14-sha1、ecdh-sha2-nistp256、ecdh-sha2-nistp384、ecdh-sha2-nistp521
信息:diffie-hellman-group14-sha1不可用。
信息:ecdh-sha2-nistp256不可用。
信息:ecdh-sha2-nistp384不可用。
信息:ecdh-sha2-nistp521不可用。
信息:检查签名:ecdsa-sha2-nistp256、ecdsa-sha2-nistp384、ecdsa-sha2-nistp521
信息:ecdsa-sha2-nistp256不可用。
信息:ecdsa-sha2-nistp384不可用。
信息:ecdsa-sha2-nistp521不可用。
信息:SSH\u MSG\u KEXINIT已发送
信息:收到SSH_MSG_KEXINIT
信息:kex:服务器: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
信息:kex:server:ssh-rsa、ssh-dss、ecdsa-sha2-nistp256、ssh-ed25519
信息:kex:服务器:aes128 ctr、aes192 ctr、aes256 ctr、arcfour256、arcfour128、aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com、aes128 cbc、3des cbc、河豚cbc、cast128 cbc、aes192 cbc、aes256 cbc、arcfour、rijndael-cbc@lysator.liu.se
信息:kex:服务器:aes128 ctr、aes192 ctr、aes256 ctr、arcfour256、arcfour128、aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com、aes128 cbc、3des cbc、河豚cbc、cast128 cbc、aes192 cbc、aes256 cbc、arcfour、rijndael-cbc@lysator.liu.se
信息:kex:服务器: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
信息:kex:服务器: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
信息:kex:服务器:无,zlib@openssh.com
信息:kex:服务器:无,zlib@openssh.com
信息:kex:服务器:
信息:kex:服务器:
信息:kex:客户:diffie-hellman-group1-sha1、diffie-hellman-group-exchange-sha1、diffie-hellman-group-exchange-sha256
INFO:kex:client:ssh-rsa、ssh-dss
信息:kex:客户:aes128中心、aes128 cbc、3des中心、3des cbc、河豚cbc
信息:kex:客户:aes128中心、aes128 cbc、3des中心、3des cbc、河豚cbc
信息:kex:客户:hmac-md5、hmac-sha1、hmac-sha2-256、hmac-sha1-96、hmac-md5-96
信息:kex:客户:hmac-md5、hmac-sha1、hmac-sha2-256、hmac-sha1-96、hmac-md5-96
信息:kex:客户:无
信息:kex:客户:无
信息:kex:客户:
信息:kex:客户:
信息:kex:服务器->客户端aes128 ctr hmac-md5无
信息:kex:客户端->服务器aes128 ctr hmac-md5无
信息:SSH\u MSG\u KEXDH\u INIT已发送
信息:期待SSH\u MSG\u KEXDH\u回复
信息:ssh\u rsa\u验证:签名为真
警告:已将“11.22.33.44”(RSA)永久添加到已知主机列表中。
信息:SSH\u MSG\u已发送新密钥
信息:收到SSH\u MSG\u新密钥
信息:SSH\u消息\u服务\u请求已发送
信息:SSH\u消息\u服务\u接收
信息:可以继续的身份验证:公钥、键盘交互、密码
信息:下一个身份验证方法:公钥
信息:可以继续的身份验证:键盘交互、密码
信息:下一个身份验证方法:键盘交互
信息:身份验证成功(键盘交互)。
JSch 0.1.53支持(并且更喜欢)diffie-hellman-group-exchange-sha256KEX,这也是服务器声称支持的,因此JSch尝试使用它

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

要解决这个问题,请强制JSch使用
diffie-hellman-group1-sha1
KEX,这是JSch 0.1.52所喜欢的:

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

我也遇到了同样的问题,我刚刚将jsch版本更改为0.1.54并得到了解决

将其添加到pom.xml中

<dependency>
   <groupId>com.jcraft</groupId>
   <artifactId>jsch</artifactId>
   <version>0.1.54</version>
</dependency>

com.jcraft
jsch
0.1.54

在尝试了许多解决方案后,下面解决了我的问题

  • 在文本编辑器中打开ssh服务器的sshd_配置并添加以下内容 文件末尾的行:

    KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
    
  • 编辑文件后,请确保重新启动ssh服务


服务器可能正在断开您的连接。服务器日志怎么说?很好,添加了0.1.52日志,新的(失败的)版本是0.1.53.jar文件。日志转储在开始时打印库版本。不要使用
StrictHostKeyChecking=no
,这样做会失去对MITM攻击的保护。这就成功了,而且我可以确认0.53下载文件的速度比旧的0.44库快得多。是否仍要将此“kex”值设置为