hierynomus / sshj

ssh, scp and sftp for java
Apache License 2.0
2.5k stars 601 forks source link

local echo with a session #224

Closed nicferrier closed 8 years ago

nicferrier commented 8 years ago

I'm trying to connect to a remote program and talk over ssh to it. But when I do that I get local echo, which obviously makes parsing the output of the program rather difficult.

Here's an example with a simple shell:

Last login: Thu Nov 12 19:44:38 2015 from 10.0.2.2
[vagrant@localhost ~]$ echo hello
echo hello
hello
[vagrant@localhost ~]$ exit
exit
logout

I can't remember if this is a thing about ssh or java or what... obviously local echo is an option in some terminals... can anyone point me to how I can stop it happening?

The code I'm using is basically the RudimentaryPTY example.

shikhar commented 8 years ago

@nicferrier it's possible to specify PTY options if you use the session.allocatePTY() option, there are various echo options on PTYMode that I'm not sure of the semantics of, you might want to poke around there.

hierynomus commented 8 years ago

@nicferrier does this also happen if you regularly connect to the server/program? Or only through SSHJ?

hierynomus commented 8 years ago

@nicferrier Do you still have this problem? If so can you share some code on how you setup your connection, and preferably a reproduction scenario?

Nogyara commented 8 years ago

I had this problem with echo too - what helped for me was like it was already mentioned above - providing one of PTYMode (PTYMode.ECHO) flags when setting up the pseudo terminal.

I provided an example in https://github.com/hierynomus/sshj/issues/273

hierynomus commented 8 years ago

See #273, closing this question.

svullo commented 7 years ago

Note for others with similar problems: I got (non-local) echo when being stupid and sending commands before I got the prompt when connecting to a Red Pitaya (Linux-based). This could maybe apply to other systems as well.