找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 25|回复: 0

浏览器运行SSH命令之 TTYD工具

[复制链接]

25

主题

12

回帖

169

积分

超级版主

积分
169
发表于 2023-10-28 21:21:10 | 显示全部楼层 |阅读模式
本帖最后由 Warren 于 2023-10-28 23:09 编辑

ttyd 是一个 C 语言编写的命令行程序,可以把任意命令行程序分享到网页上操作,可以看做是个网页版的远程终端,
支持 Linux、macOS、FreeBSD系统,还可以运行在 OpenWrt/LEDE 之类的嵌入式系统上。


ttyd安装
1、安装需要的组件
  1. apt install ttyd
复制代码


2、运行ttyd  
创建ttyd.service服务文件并写入以下内容(蓝色内容
  1. vim /lib/systemd/system/ttyd.service
复制代码
  1. [Unit]
  2. Description=ttyd daemon
  3. After=syslog.target
  4. After=network.target

  5. [Service]
  6. ExecStart=/usr/bin/ttyd login
  7. Type=simple
  8. Restart=always
  9. User=root
  10. Group=root
  11. LimitNOFILE=512
  12. LimitMEMLOCK=infinity
  13. LimitSTACK=infinity

  14. [Install]
  15. WantedBy=multi-user.target
复制代码
启动ttyd服务:systemctl start ttyd.service
设置开机启动:systemctl enable ttyd.service
查看运行状态:systemctl status ttyd.service
  1. systemctl daemon-reload
  2. systemctl start ttyd.service
  3. systemctl enable ttyd.service
  4. systemctl status ttyd.service
复制代码


ttyd一些配置
1、指定端口访问
ttyd -p 8000 bash

2、设置指定账号密码才能登入
例如我们指定用户名和密码都是 admin,格式为 username:password

ttyd -p 8000 -c admin:admin bash

3、自动打开浏览器(打开的是系统默认的浏览器)

ttyd -p 8000 -B bash
4、SSH 终端
这样的话,打开浏览器之后就需要 SSH 登录,输入正确的 SSH 用户名和密码后才能使用

ttyd login
更多请参考https://github.com/tsl0922/ttyd





您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Home!

GMT+8, 2025-12-6 12:34 , Processed in 0.031574 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表