Is there any ssh client supporting java.nio.channels.SocketChannel?

client, java, nio, selector, ssh

Solution

As of 2015 there is an nio fork of JSCH:

https://github.com/lucastheisen/jsch-nio

I've used it and it does improve throughput significantly.

Problem

I developed a proxy application, by which users can telnet to it and send a "connect to xxx" command to connect to a ssh server. I use JSch as my ssh client: ``` JSch jsch = new JSch(); Session session = jsch.getSession(username, ip, 22); Channel channel = session.openChannel("shell"); InputStream inp = channel.getInputStream(); OutputStream oup = channel.getOutputStream(); MyReader myReader = new MyReader(userOutputStream, inp); new Thread(myReader).start(); MyWriterThread myWriter = new MyWriter(userInputStream, oup); new Thread(myWriter).start(); ``` then deal with input and output respectively in these two new threads. But the proxy's performance dropped rapidly with the increase of user amount for too many concurrent threads. So I want to use java.nio.channels.Selector and SocketChannel to decrease thread amount. However I can't find a ssh client supporting java.nio.*(e.g.: JSch, Apache sshd, sshtools, etc.). Does any other ssh client supporting java nio? Or are there some methods can connecting input/output stream with Selector and SocketChannel? Thanks a lot!

Original source