vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
7.19k stars 280 forks source link

No ioctl when tunneling #108

Closed alfem closed 3 years ago

alfem commented 3 years ago

I am deeply impressed by websocat features, but I bumped into this problem:

To give (linux) support to friends/family/colleagues behind their firewalls/routers, I asked them to install websocat and tunnel a bash session to my server on the Internet.

They use something like:

./websocat_amd64-linux-static ws://myserver.test:443 sh-c:'bash -i 2>&1' --binary

In my server, I have started this:

./websocat_amd64-linux-static --binary --exit-on-eof ws-l:0.0.0.0:443 -

After connection is established I can issue some simple commands, but any terminal control fails. I can not edit with vi, nor use tab completion.

Probably I am missing some tuning parameters, or it is a terminal issue. Any clue would be really appreciated.

vi commented 3 years ago

Note that this setup looks insecure. Although port is 443, it uses unencrypted and unauthenticated connection, allowing easy illegitimate access, especially if network is compromised. It may be OK for one-off experiment, but will lead to problems if used persistently or deployed on multiple instances.

The problem seems to be related to the one I encountered when using socat.

To make a rich terminal, you can combine Websocat with Socat, which can use PTYs:

shell side:

./websocat_amd64-linux-static -b ws://myserver.test:443 exec:/usr/bin/socat --exec-args - exec:"bash -li",pty,stderr,setsid,sigint,sane

user side:

socat file:`tty`,raw,echo=0  exec:'./websocat_amd64-linux-static --binary --exit-on-eof ws-l\:0.0.0.0\:443 -'

Current version of Websocat does not support controlling PTYs directly. This feature may be added later.

alfem commented 3 years ago

Note that this setup looks insecure.

I know. I am only testing the setup right now.

To make a rich terminal, you can combine Websocat with Socat, which can use PTYs:

It works! Thanks a lot!

Current version of Websocat does not support controlling PTYs directly. This feature may be added later.

I wish!