Terminal integration in LUCI: luci-app-ttyd

This package intigrates ttyd in LUCI.

term

The project is still alpha and needs some optimization and improvements. This is my first development for OpenWRT / LEDE. Module development with Lua for/with LuCI are the naked horror ;).

The source: https://github.com/ozon/luci-app-ttyd

9 Likes

That would be very helpful ! Nice!

Interesting.
But I get lost with the Create/uci-defaults function. Why is it included? (does it actually do anything?)

The uci-defaults script should be there as a normal included file, like I think you already have.

For now I have removed the uci-defaults stuff.

A ready to use ipk packet can be found on https://github.com/ozon/luci-app-ttyd/releases.
It is dependent on the ttyd package.

I downloaded the ipk from github (luci-app-ttyd_0.0.1-1_all.ipk) but I end up with the blank black screen when I go to System->Terminal.

If it helps, that's how the installation went:

EA8500 in /tmp # opkg install ./luci-app-ttyd_0.0.1-1_all.ipk
Installing luci-app-ttyd (0.0.1-1) to root...
Configuring luci-app-ttyd.
once 1

I do have ttyd installed as well.

Hi stangri,
please try this:

Start the ttyd service with /etc/init.d/ttyd start and check the log with logread -e ttyd
Check System->Terminal again if the last line look like
Thu Sep 21 14:56:31 2017 daemon.err ttyd[771]: [2017/09/21 14:56:31:4242] NOTICE: started process, pid: 8190

You can also check if ttyd generally works with killall ttyd; ttyd /bin/sh
Try <your_router_ip>:7681

In case of further problems feel free to send me your complete log via pm.

I get ERROR on binding fd 6 to port 7681.

What can I do now?

root@LEDE:~# /etc/init.d/ttyd start
once 1
shell /bin/ash
port 7681
root@LEDE:~# logread -e ttyd
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1634] NOTICE: Initial logging level 7
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1780] NOTICE: Libwebsockets version: 2.0.3 buildbot@builds-02.infra.lede-project.org-
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1789] NOTICE: IPV6 compiled in and enabled
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1797] NOTICE: libev support not compiled in
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1805] NOTICE: libuv support not compiled in
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1817] NOTICE:  Threads: 1 each 1024 fds
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1827] NOTICE:  mem: platform fd map:  4096 bytes
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1836] NOTICE:  Compiled with OpenSSL support
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1844] NOTICE:  SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1852] NOTICE: Creating Vhost 'default' port 7681, 2 protocols
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1861] ERR: ERROR on binding fd 6 to port 7681 (-1 125)
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1869] ERR: Failed to create default vhost
Fri Dec  7 10:08:28 2018 daemon.err ttyd[20671]: [2018/12/07 10:08:28:1878] ERR: libwebsockets init failed

Hey i have this exact same problem, have you solved it?

2 Likes

Nice job!
If someone is looking for a smaller solution then have a look https://github.com/meefik/websocket.sh
But you'll have to use buildroot to enable telnetd in busybox. Also please note that it doesn't support TLS so don't use it over internet

Hi!
I'm very interested in this addon, however it doesn't seem to run properly on my device:


It seems that ttyd service is functioning correctly:

Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]: ttyd 1.6.3 (libwebsockets 4.2.1-unknown)
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]: tty configuration:
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:   start command: /bin/sh
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:   close signal: SIGHUP (1)
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:   terminal type: xterm-256color
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]: LWS: 4.2.1-unknown, loglevel 7
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]: NET CLI SRV H1 H2 WS ConMon IPV6-off
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:    /usr/lib/libwebsockets-evlib_uv.so
Wed Oct 18 17:40:43 2023 daemon.err ttyd[5255]: [2023/10/18 17:40:43:1405] N:  Using foreign event loop...
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:  ++ [wsi|0|pipe] (1)
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:  ++ [vh|0|netlink] (1)
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:  ++ [vh|1|default|br-lan|br-lan|7681] (2)
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]: lws_socket_bind: nowsi: source ads 192.168.1.1
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:  ++ [wsi|1|listen|default|br-lan|7681] (2)
Wed Oct 18 17:40:43 2023 daemon.notice ttyd[5255]:  Listening on port: 7681
Wed Oct 18 17:41:59 2023 daemon.notice ttyd[5255]: received signal: SIGTERM (15), exiting...
Wed Oct 18 17:41:59 2023 daemon.notice ttyd[5255]: send ^C to force exit.
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]: ttyd 1.6.3 (libwebsockets 4.2.1-unknown)
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]: tty configuration:
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:   start command: /bin/login
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:   close signal: SIGHUP (1)
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:   terminal type: xterm-256color
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]: LWS: 4.2.1-unknown, loglevel 7
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]: NET CLI SRV H1 H2 WS ConMon IPV6-off
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:    /usr/lib/libwebsockets-evlib_uv.so
Wed Oct 18 17:43:25 2023 daemon.err ttyd[5494]: [2023/10/18 17:43:25:9816] N:  Using foreign event loop...
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:  ++ [wsi|0|pipe] (1)
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:  ++ [vh|0|netlink] (1)
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:  ++ [vh|1|default||7681] (2)
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]: lws_socket_bind: nowsi: source ads 0.0.0.0
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:  ++ [wsi|1|listen|default||7681] (2)
Wed Oct 18 17:43:25 2023 daemon.notice ttyd[5494]:  Listening on port: 7681

Could you try it with OpenWrt 23.05 if it is the same or not?

What fixed this for me on 21.0.2 is enabling SSL, using the same cert & key as uhttpd.

What was happening for me was my browser silently blocking non-secure content on a secure page. I had to look at the dev console in the browser to see the block.

Where do find the uhttpd cert & key info?
I turned SSL on in the menu, but same error in firefox.

ssl enabled,
/etc/uhttpd.crt - path to cert
/etc/uhttpd.key - path to key

STILL dosen't work, sigh...

Hi.
Any news about ttyd?
I enabled ssl for LuCI and I'd like to be able to use ssh console via browser. How can I configure ttyd properly?



this is helping: https://github.com/openwrt/luci/issues/5347#issuecomment-1902762357

I visited https://192.168.1.1:7681 afterwards and allowed the connection and now its working, would love to see that way easier