rtty:反向代理WebTTY,Linux远程维护调试工具

作者: 赵建辉 2018-03-26 09:02:20

rtty 是一个反向代理 WebTTY。它由客户端和服务端组成。服务端采用 Go 语言实现, 以及使用了 vue + iview。你可以基于你设置的设备 ID(不设置则为设备的 MAC 地址)通过 Web 浏览器访问你的任意一台终端。


rtty 非常适合远程维护你的或者你公司的部署在全球各地的成千上万的 Linux 设备。




 


特性


部署简单,使用方便


反向代理


根据你设置的 ID 连接你的设备


基于 Xterm.js 的全功能终端


支持 SSL: openssl、mbedtls、 CyaSSl(wolfssl)


支持上传文件到设备


支持从设备下载文件


支持远程执行命令


跨平台: macOS、Linux、FreeBSD/OpenBSD、OpenWrt/LEDE


 


客户端依赖


libubox - 用于 OpenWrt 的 C 工具函数库,但也可以用于其他 Linux 系统中。


libuwsc - 一个轻量的针对嵌入式 Linux 的基于 libubox 的 WebSocket 客户端 C 库。


ustream-ssl - 如果你需要支持 SSL


mbedtls - 如果你选择 mbedtls 作为你的 SSL 后端


CyaSSl(wolfssl) - 如果你选择 wolfssl 作为你的 SSL 后端


openssl - 如果你选择 openssl 作为你的 SSL 后端


 


部署服务端


安装


curl https://raw.githubusercontent.com/zhaojh329/rttys/master/install.sh | sudo sh


 


手动运行


rttys -cert /etc/rttys/rttys.crt -key /etc/rttys/rttys.key


 


后台运行


sudo /etc/init.d/rttys start


 


如何编译和安装 rtty 客户端


针对 Linux 发行版,例如 Ubuntu 和 CentOS


安装编译工具:


sudo apt install gcc cmake git  # For Ubuntu


yum install gcc cmake git   # For Centos


编译和安装依赖软件包:


sudo apt install libjson-c-dev  # For Ubuntu


sudo apt install json-c-devel   # For Centos


git clone https://git.openwrt.org/project/libubox.git


cd libubox && cmake -DBUILD_LUA=OFF . && sudo make install


git clone https://github.com/zhaojh329/libuwsc.git


cd libuwsc && cmake -DUWSC_SSL_SUPPORT=OFF . && sudo make install


编译和安装 rtty:


git clone https://github.com/zhaojh329/rtty.git


cd rtty && cmake . && sudo make install


运行 rtty ,将下面的参数替换为你自己的参数:


sudo rtty -I 'My-device-ID' -h 'your-server' -p 5912 -a -v -s -d 'My Device Description'


查询在线设备列表:


curl -k https://your-server:5912/devs


[{"id":"My-device-ID","description":"My device"}]


 


嵌入式Linux平台


你需要自行交叉编译。


 


如何在 OpenWRT 中使用


安装:


opkg update


opkg list | grep rtty


opkg install rtty-nossl


如果安装失败,你可以自己编译。


配置服务器参数:


uci add rtty rtty   # If it's the first configuration


uci set rtty.@rtty[0].host='your server host'


uci set rtty.@rtty[0].port='your server port'


你可以给你的设备自定义一个 ID。如果未指定,rtty 将使用指定的网络接口的 MAC 地址作为其 ID, 以 MAC 地址作为 ID 的格式为:1A2A3A4A5A6A。


uci set rtty.@rtty[0].id='your-device-id'


使用 SSL:


uci set rtty.@rtty[0].ssl='1'


保存配置并应用:


uci commit


/etc/init.d/rtty restart


 


如何使用


使用你的 Web 浏览器访问你的服务器: https://your-server-host:5912,然后点击连接按钮。




你可以非常方便的将 rtty 嵌入到你现有的平台: https://your-server-host:5912?id=your-id。


自动登录: https://your-server:5912/?id=device-id&username=device-username&password=device-password。


 


上传文件和下载文件


使用快捷键打开菜单: Ctrl+Shift+f。






 


远程执行命令


curl -k https://your-server:5912/cmd -d '{"devid":"test","username":"test","password":"123456","cmd":"ls","params":["/"],"env":[]}'


{"Err":0,"msg":"","code":0,"stdout":"bin dev etc lib mnt overlay proc rom root sbin sys tmp usr var www ","stderr":""}


 


贡献代码


如果你想帮助 rtty(https://github.com/zhaojh329/rtty)变得更好,请参考 https://github.com/zhaojh329/rtty/blob/master/CONTRIBUTING_ZH.md。


 


Remmina:一个Linux下功能丰富的远程桌面共享工具:http://www.linuxdiyf.com/linux/30659.html


rdiff-backup:一个Linux中的远程增量备份工具:http://www.linuxdiyf.com/linux/30658.html


不错的多窗口Windows/Linux远程桌面连接工具-宝塔远程桌面助手:http://www.linuxdiyf.com/linux/30161.html


解决:利用Xware在centos上搭建远程下载器:http://www.linuxdiyf.com/linux/29970.html


在Windows和Ubuntu上安装VNC连接远程服务器:http://www.linuxdiyf.com/linux/29919.html

相关资讯