From 1cdda3c4d7fe6358cd9d8b2ffa22c96c303c6283 Mon Sep 17 00:00:00 2001 From: "ithink.chan" Date: Mon, 15 Jul 2019 14:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Gotty=20=E7=9A=84=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E4=B8=8E=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ithink.chan --- .../Application/Gotty/Gotty_的安装与配置.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Software/Application/Gotty/Gotty_的安装与配置.md diff --git a/Software/Application/Gotty/Gotty_的安装与配置.md b/Software/Application/Gotty/Gotty_的安装与配置.md new file mode 100644 index 0000000..524735a --- /dev/null +++ b/Software/Application/Gotty/Gotty_的安装与配置.md @@ -0,0 +1,72 @@ +# Gotty 的安装与配置 + +## 下载与安装 + +到 的 Release 中下载对应版本的 gotty 程序,解压后从命令行运行即可。 + +## 配置文件 + +可以通过命令行参数运行 gotty 程序,也可以为其指定配置文件,gotty 源码中有参考配置文件,以下是一个比较简单实用的配置(“//”为行注释): + +```sh +// [string] Address to listen, all addresses will be used when empty +// address = "" + +// [string] Port to listen +port = "9000" + +// [bool] Permit clients to write to the TTY +permit_write = true + +// [bool] Enable basic authentication +enable_basic_auth = true + +// [string] Default username and password of basic authentication (user:pass) +// To enable basic authentication, set `true` to `enable_basic_auth` +credential = "user:pass" + +// [bool] Enable TLS/SSL +enable_tls = true + +// [string] Default TLS certificate file path +tls_crt_file = "./gotty.crt" + +// [string] Default TLS key file path +tls_key_file = "./gotty.key" + +// [string] Title format of browser window +// Available variables are: +// Command Command string +// Pid PID of the process for the client +// Hostname Server hostname +// RemoteAddr Client IP address +title_format = "GoTTY - {{ .Command }} ({{ .Hostname }})" + +// [int] Maximum connection to gotty, 0(default) means no limit. +// max_connection = 1 + +// [bool] Accept only one client and exit gotty once the client exits +// once = true +``` + +上面配置文件使 gotty 启用 https,使用用户名“user”和密码“pass”来登陆。并定制了网页标题头。 + +https 依赖于 crt 和 key 这两个证书文件,你可以用以下命令创建临时的证书文件(或到证书管理网站申请正式证书)。 + +```sh +openssl req -x509 -nodes -days 9999 -newkey rsa:2048 -keyout gotty.key -out gotty.crt +``` + +## 运行 + +一个可以与多个客户端分享终端,并且使用配置文件的命令和参数如下: + +```sh +gotty --config= tmux new -A -s gotty +``` + +如果配置文件与本文示例一致,则上列命令与下列命令等同: + +```sh +gotty -t --tls-crt=./gotty.crt --tls-key=./gotty.key -w -p "9000" -c "user:pass" tmux new -A -s gotty +```