介绍
ttyd 是用与在Web上共享终端的简单命令行工具
ps:建议不要在生产环境上使用,自己在测试环境上玩玩就可以了
GitHub地址:https://github.com/tsl0922/ttyd/blob/main/README.md
安装
[root@node1 aihuidi]# wget https://github.com/tsl0922/ttyd/releases/download/1.6.3/ttyd.x86_64 --no-check-certificate
[root@node1 aihuidi]# mv ttyd.x86_64 ttyd
[root@node1 aihuidi]# chmod +x ttyd
[root@node1 aihuidi]# mv ttyd /usr/sbin/
[root@node1 aihuidi]# ttyd -v
使用
[root@node1 aihuidi]# ttyd bash
浏览器访问IP:7681端口
为ttyd创建一个ststemd服务,增加安全性:设置用户名,密码验证
[root@node1 ~]# cat /etc/systemd/system/ttyd.service
[Unit]
Description=ttyd
After=network.target
[Service]
#ExecStart=/usr/sbin/ttyd bash
ExecStart=/usr/sbin/ttyd -c aihuidi:password@jdf946 bash
[Install]
WantedBy=multi-user.target
[root@node1 ~]#
[root@node1 ~]# systemctl daemon-reload
[root@node1 ~]# systemctl start ttyd
[root@node1 ~]# systemctl status ttyd
● ttyd.service - ttyd
Loaded: loaded (/etc/systemd/system/ttyd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2021-04-19 16:28:31 CST; 3s ago
Main PID: 65193 (ttyd)
CGroup: /system.slice/ttyd.service
└─65193 /usr/sbin/ttyd bash
Apr 19 16:28:31 node1 systemd[1]: Started ttyd.
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4867] N: ttyd 1.6.3-3b174da (libwebsockets 4.1.6-)
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4868] N: tty configuration:
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4868] N: start command: bash
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4868] N: close signal: SIGHUP (1)
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4868] N: terminal type: xterm-256color
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4868] N: LWS: 4.1.6-, loglevel 7
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4868] N: NET SRV H1 WS IPV6-off
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4869] N: Using foreign event loop...
Apr 19 16:28:31 node1 ttyd[65193]: [2021/04/19 16:28:31:4869] N: Listening on port: 7681
[root@node1 ~]# systemctl stop ttyd
[root@node1 ~]# vim /etc/systemd/system/ttyd.service
[root@node1 ~]# systemctl daemon-reload //让daemon生效
[root@node1 ~]# systemctl start ttyd