jbtronics / ESP32Console

Extensible UART console library for ESP32 with useful included commands.
MIT License
157 stars 16 forks source link

Support for TELNET protocol? #3

Open urseppenberger opened 2 years ago

urseppenberger commented 2 years ago

I found your library through a hint of hackaday. Congratulations and many thanks.

I use the ESP32 and ESP8266 chips for home automation. Some of them are connected to mains power. It is therefore much safer for my laptop, if I connect using WiFi to the devices instead of a serial connection. I use a TELNET library for this. Your serial library is much more advanced and offers interesting functions to look at the system itself. Would it be possible for you to support the TELNET protocol?

Kind regards, Urs.

jbtronics commented 2 years ago

In Principle this should be possible: Telenet as a protocol is pretty simple (more or less just a simple TCP connection). The challenge I see is to connect the telnet connection to stdin and stdout (which are used for the input and output of the commands), especially if you wanna use both serial terminal and telnet connection.

Another point I worry about, is that telnet is pretty unsafe, as it has no support for encryption or built-in authentication. As ESP32Console let you do many security critical things, exposing it via telnet will introduce a large security hole in many projects.

urseppenberger commented 2 years ago

Many thanks for your detailed feedback on my question. Your points are definitely valid.

The first point could be solved by just allowing one connection, either via TCP or via Serial.

The second point is more difficult. TELNET is a deprecated protocol by the IETF since it does not support encryption. Encryption would mean to implement SSH instead of TELNET, I did not dare to ask for this. A first line of defence could be username/password to have at least a simple authentication, this is better than nothing. Secondly TELNET access should only enabled for test devices, not for operational devices.

jbtronics commented 2 years ago

Somebody have ported libssh for the ESP32 so in theory it should be possible to implement SSH. The problem is that libssh is pretty low level and you have to write much code to use it properly (at least that's what it looked like from the examples). Also I don't know how much flash and RAM this needs.