From 555f44f87dfb1709731d2d1d52536b11c9cdff9c Mon Sep 17 00:00:00 2001 From: butlerx Date: Mon, 5 Oct 2020 12:32:09 +0100 Subject: [PATCH] update docs for v2 --- README.md | 33 ++++++++++++++++++++++++++++----- docs/flags.md | 6 +++--- docs/https.md | 6 +++--- docs/nginx.md | 2 +- docs/service.md | 4 ++-- src/main.ts | 4 ++-- src/server.ts | 3 ++- 7 files changed, 41 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 557e1ef..534908b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,30 @@ yarn global add wetty ## Usage ```sh -wetty [-h] [--port PORT] [--base BASE] [--sshhost SSH_HOST] [--sshport SSH_PORT] [--sshuser SSH_USER] [--host HOST] [--command COMMAND] [--forcessh] [--bypasshelmet] [--title TITLE] [--sslkey SSL_KEY_PATH] [--sslcert SSL_CERT_PATH] +$ wetty --help +Options: + --help, -h Print help message [boolean] + --version Show version number [boolean] + --conf config file to load config from [string] + --ssl-key path to SSL key [string] + --ssl-cert path to SSL certificate [string] + --ssh-host ssh server host [string] + --ssh-port ssh server port [number] + --ssh-user ssh user [string] + --title window title [string] + --ssh-auth defaults to "password", you can use "publickey,password" + instead [string] + --ssh-pass ssh password [string] + --ssh-key path to an optional client private key (connection will be + password-less and insecure!) [string] + --force-ssh Connecting through ssh even if running as root [boolean] + --known-hosts path to known hosts file [string] + --base, -b base path to wetty [string] + --port, -p wetty listen port [number] + --host wetty listen host [string] + --command, -c command to run in shell [string] + --bypass-helmet disable helmet from placing security restrictions [boolean] + ``` Open your browser on `http://yourserver:3000/wetty` and you will prompted to @@ -44,11 +67,11 @@ user before hand. If you run it as root it will launch `/bin/login` (where you can specify the user name), else it will launch `ssh` and connect by default to `localhost`. The -SSH connection can be forced using the `--forcessh` option. +SSH connection can be forced using the `--force-ssh` option. -If instead you wish to connect to a remote host you can specify the `--sshhost` -option, the SSH port using the `--sshport` option and the SSH user using the -`--sshuser` option. +If instead you wish to connect to a remote host you can specify the `--ssh-host` +option, the SSH port using the `--ssh-port` option and the SSH user using the +`--ssh-user` option. Check out the [Flags docs](https://github.com/butlerx/wetty/blob/master/docs/flags.md) for a diff --git a/docs/flags.md b/docs/flags.md index 2e2a531..b867f49 100644 --- a/docs/flags.md +++ b/docs/flags.md @@ -14,12 +14,12 @@ the `login` binary rather than ssh. If no host is specified it will use `localhost` as the ssh host. If instead you wish to connect to a remote host you can specify the host with -the `--sshhost` flag and pass the IP or DNS address of the host you want to +the `--ssh-host` flag and pass the IP or DNS address of the host you want to connect to. ## Default User -You can specify the default user used to ssh to a host using the `--sshuser`. +You can specify the default user used to ssh to a host using the `--ssh-user`. This user can overwritten by going to `http://yourserver:3000/wetty/ssh/`. If this is left blank a user will be prompted to enter their username when they connect. @@ -27,7 +27,7 @@ be prompted to enter their username when they connect. ## SSH Port By default WeTTy will try to ssh to port `22`, if your host uses an alternative -ssh port this can be specified with the flag `--sshport`. +ssh port this can be specified with the flag `--ssh-port`. ## WeTTy URL diff --git a/docs/https.md b/docs/https.md index 59f4e1d..8632e3e 100644 --- a/docs/https.md +++ b/docs/https.md @@ -6,11 +6,11 @@ either using WeTTy behind a proxy or directly. See docs for [NGinX](./nginx.md) and [Apache](./apache.md) for running behind a proxy. -To run WeTTy directly with SSL use both the `--sslkey` and `--sslcert` flags and -pass them the path too your cert and key as follows: +To run WeTTy directly with SSL use both the `--ssl-key` and `--ssl-cert` flags +and pass them the path too your cert and key as follows: ```bash -wetty --sslkey key.pem --sslcert cert.pem +wetty --ssl-key key.pem --ssl-cert cert.pem ``` If you don't have SSL certificates from a CA you can create a self signed diff --git a/docs/nginx.md b/docs/nginx.md index 97f69e1..32ecf98 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -19,7 +19,7 @@ Put the following configuration in your nginx conf: ```nginx location ^~ /wetty { - proxy_pass http://127.0.0.1:3000/WeTTy; + proxy_pass http://127.0.0.1:3000/wetty; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; diff --git a/docs/service.md b/docs/service.md index 07d5735..7e21e6c 100644 --- a/docs/service.md +++ b/docs/service.md @@ -7,7 +7,7 @@ bundled with the npm package to make this easier. ```bash $ yarn global add wetty -$ sudo cp ~/.config/yarn/global/node_modules/wetty/bin/wetty.conf /etc/init +$ sudo cp ~/.config/yarn/global/node_modules/wetty/conf/wetty.conf /etc/init $ sudo start wetty ``` @@ -15,7 +15,7 @@ $ sudo start wetty ```bash $ yarn global add wetty -$ cp ~/.config/yarn/global/node_modules/wetty/bin/wetty.service ~/.config/systemd/user/ +$ cp ~/.config/yarn/global/node_modules/wetty/conf/wetty.service ~/.config/systemd/user/ $ systemctl --user enable wetty $ systemctl --user start wetty ``` diff --git a/src/main.ts b/src/main.ts index 25d37ae..668304c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,7 @@ */ import yargs from 'yargs'; import { logger } from './shared/logger.js'; -import { startServer } from './server.js'; +import { start } from './server.js'; import { loadConfigFile, mergeCliConf } from './shared/config.js'; const opts = yargs @@ -94,7 +94,7 @@ if (!opts.help) { loadConfigFile(opts.conf) .then(config => mergeCliConf(opts, config)) .then(conf => - startServer(conf.ssh, conf.server, conf.command, conf.forceSSH, conf.ssl), + start(conf.ssh, conf.server, conf.command, conf.forceSSH, conf.ssl), ) .catch((err: Error) => { logger.error(err); diff --git a/src/server.ts b/src/server.ts index 3efe3ce..27f9ec5 100644 --- a/src/server.ts +++ b/src/server.ts @@ -2,6 +2,7 @@ * Create WeTTY server * @module WeTTy */ +import type SocketIO from 'socket.io'; import type { SSH, SSL, Server } from './shared/interfaces.js'; import { getCommand } from './server/command.js'; import { logger } from './shared/logger.js'; @@ -20,7 +21,7 @@ import { * @name startServer * @returns Promise that resolves SocketIO server */ -export async function startServer( +export async function start( ssh: SSH = sshDefault, serverConf: Server = serverDefault, command: string = defaultCommand,