java.io.IOException: End of IO Stream Read

wiselight 2017-03-09 10:26:18
最近工作涉及到与服务器通信问题,使用Jsch来进行SSH连接时,报这个异常

java.io.IOException: End of IO Stream Read.求大神帮助啊
...全文
4311 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenfrigate 2018-05-09
  • 打赏
  • 举报
回复
我用的是0.1.54版本,按照六楼的指点做了设置,报了其他的错。之后用1.8版本的java后,问题解决。
  • 打赏
  • 举报
回复
一版都是session的加密配置不合适配置
Properties sshConfig = new Properties();  
	            sshConfig.put("StrictHostKeyChecking", "no");  
	            sshConfig.put("cipher.s2c","aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc");
	            sshConfig.put("cipher.c2s","aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,blowfish-cbc,aes192-ctr,aes192-cbc,aes256-ctr,aes256-cbc");
	            sshConfig.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");
	            //sshConfig.put("kex", "diffie-hellman-group1-sha1");
	            session.setConfig(sshConfig); 
加上这段配置试一下,我是0.1.54版本,也遇到这个问题,然后还可以换下java版本,升级到8估计也能解决这种问题,你多试一下吧
yezi04070105 2017-11-20
  • 打赏
  • 举报
回复
楼主,我也遇到一样的问题了,头疼中,能分享下解决方案吗?
wiselight 2017-03-09
  • 打赏
  • 举报
回复
在某些服务器上能够连接,但在新的设备好像就出问题了。 但是用shell工具能登录。 连接代码如下: public boolean _connect() throws Exception { boolean ret = false; try { JSch jsch = new JSch(); session = jsch.getSession(username, host, port); session.setPassword(password); java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.setTimeout(connectTimeout); session.connect(); channel = session.openChannel("shell"); channel.setOutputStream(baOut); ((ChannelShell) channel).setPty(true); channel.connect(connectTimeout); LogUtils.info("SSH " + username + "@" + host + " connect successfully..."); StringBuffer welcomeMessage = new StringBuffer(); while (true) { welcomeMessage.append(read()); if (this.endsWithPrompt(welcomeMessage.toString())) { break; } } LogUtils.info(welcomeMessage); ret = true; } catch (JSchException e) { LogUtils.error("SSH " + username + "@" + host + " connect failed! " + e.getMessage()); e.printStackTrace(); } return ret; } 异常信息: SSH root@10.209.4.180 connect failed! Session.connect: java.io.IOException: End of IO Stream Read 说明可能在 session.connect();就出错了
tianfang 2017-03-09
  • 打赏
  • 举报
回复
贴出错误日志,出错误的相关代码
tianfang 2017-03-09
  • 打赏
  • 举报
回复
就是你的config中可能需要增加更多的参数
tianfang 2017-03-09
  • 打赏
  • 举报
回复
SSH服务加密方式有多种,需要查一下具体的方式

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧