Pseudo terminal to use with ssh in java

2019-09-12 15:16发布

I am writing a program to connect to a remote server with ssh and provide the user with a shell terminal.

I've tried JSch and sshj -- both can connect properly but just hooking up the input/output streams of their shell channels to System.in and System.out produces funky output. I know why--the documentations for both JSch and sshj say that they don't have terminal emulation built in so the input/output is ugly. (sshj calls this implementation a "rudimentary PTY")

I also have a selection of terminal emulators: JTerm, DragonConsole, and Terminator.

My goal is to start a terminal emulator window and do something similar to plugging the input/output streams from the shell channel into the emulator.

Alternatives like suggesting a way for me to process input/output to/from the shell channel myself to get rid of the junk characters would be appreciated as well--that's the main problem.

Edit: Here is the sshj "rudimentary PTY"

And here's the JSch version

标签: java ssh pty
1条回答
一纸荒年 Trace。
2楼-- · 2019-09-12 16:03

JCTerm has implemented a terminal emulator. Its source code is available at https://github.com/ymnk/jcterm , and you can try its online-demo at http://wiredx.net/jcterm/ .

查看更多
登录 后发表回答