jline2 - Java SSH server with JLine3 and JSch client -


i'm trying migrate java based ssh server using apache sshd-core using jline2 jline3 , using jsch client connect , execute shell commands. jline2, works fine.

with jline3, works fine when executing commands on ssh client in osx. however, can't seem working jsch.

attaching stacktrace below:

exception in thread "thread-4" org.jline.reader.endoffileexception: org.jline.utils.closedexception: inputstreamreader closed.     @ org.jline.keymap.bindingreader.readcharacter(bindingreader.java:140)     @ org.jline.keymap.bindingreader.readbinding(bindingreader.java:109)     @ org.jline.keymap.bindingreader.readbinding(bindingreader.java:60)     @ org.jline.reader.impl.linereaderimpl.readbinding(linereaderimpl.java:709)     @ org.jline.reader.impl.linereaderimpl.readline(linereaderimpl.java:515)     @ org.jline.reader.impl.linereaderimpl.readline(linereaderimpl.java:385)     @ test.ssh.jline3.echosshsessioninstance.run(echosshsessioninstance.java:64)     @ java.lang.thread.run(thread.java:745) caused by: org.jline.utils.closedexception: inputstreamreader closed.     @ org.jline.utils.inputstreamreader.read(inputstreamreader.java:191)     @ org.jline.utils.nonblockingreader.run(nonblockingreader.java:273)     ... 1 more 

sample project can found @ github

thanks in advance.

the sample project has been updated working jline3 code. needed use pipedinputstream , pipedoutputstream this. e.g:

jsch jsch = new jsch(); session session = jsch.getsession("admin", "localhost", 8022); session.setpassword("xxx"); properties config = new properties(); config.put("stricthostkeychecking", "no"); session.setconfig(config); session.connect(); channelshell channel = (channelshell) session.openchannel("shell"); pipedinputstream pis = new pipedinputstream(); pipedoutputstream pos = new pipedoutputstream(); channel.setinputstream(new pipedinputstream(pos)); channel.setoutputstream(new pipedoutputstream(pis)); channel.connect(); pos.write("exit\r".getbytes(standardcharsets.utf_8)); stringbuilder sb = new stringbuilder(); int i; while ((i = pis.read()) != '\n') {     sb.append((char) i); } assertequals("exit\r", sb.tostring()); channel.disconnect(); session.disconnect(); 

thanks gnodet's response


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -