From 7b9adef7e585f22e6430b076c6b225e6cf9928d3 Mon Sep 17 00:00:00 2001 From: Janos Kasza Date: Tue, 21 Jan 2020 17:40:15 +0100 Subject: [PATCH] Removed --sshaskuser option as it's not necessary --- README.md | 8 ++++---- bin/ssh-with-user | 9 --------- docs/API.md | 1 - index.js | 6 ------ package.json | 2 +- src/server/cli/options.ts | 1 - src/server/cli/parseArgs.ts | 1 - src/server/command/index.ts | 7 +++---- src/server/command/ssh.ts | 6 +++--- src/server/interfaces.ts | 1 - src/server/wetty/index.ts | 2 +- 11 files changed, 12 insertions(+), 32 deletions(-) delete mode 100755 bin/ssh-with-user diff --git a/README.md b/README.md index 9aa2770..43d2fb3 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,9 @@ ![All Contributors](https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square) + + ![Version](https://img.shields.io/badge/version-1.1.7-blue.svg?cacheSeconds=2592000) ![Node Version](https://img.shields.io/badge/node-%3E%3D6.9-blue.svg) [![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](https://github.com/butlerx/wetty/tree/master/docs) @@ -33,7 +35,7 @@ yarn global add wetty ## Usage ```sh -wetty [-h] [--port PORT] [--base BASE] [--sshhost SSH_HOST] [--sshport SSH_PORT] [--sshuser SSH_USER] [--sshaskuser] [--host HOST] [--command COMMAND] [--forcessh] [--bypasshelmet] [--title TITLE] [--sslkey SSL_KEY_PATH] [--sslcert SSL_CERT_PATH] +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] ``` Open your browser on `http://yourserver:3000/wetty` and you will prompted to @@ -46,9 +48,7 @@ SSH connection can be forced using the `--forcessh` 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. Alternatively you can ask the user from the stard input of -the terminal later (and ignoring `--sshuser`) if using the `--sshaskuser` -option. +`--sshuser` option. Check out the [Flags docs](https://github.com/butlerx/wetty/blob/master/docs/flags.md) for a diff --git a/bin/ssh-with-user b/bin/ssh-with-user deleted file mode 100755 index 5df1e64..0000000 --- a/bin/ssh-with-user +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -e - -while [ -z "${username}" ]; do - echo -n "localhost login: " - read username -done -ssh -l "${username}" $@ diff --git a/docs/API.md b/docs/API.md index c06bdb4..3f6e953 100644 --- a/docs/API.md +++ b/docs/API.md @@ -21,7 +21,6 @@ Starts WeTTy Server | :------------------------ | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------- | | [ssh] | `Object` | | SSH settings | | [ssh.user] | `string` | `"''"` | default user for ssh | -| [ssh.askuser] | `boolean` | `false` | ask ssh user from the standard input | | [ssh.host] | `string` | `"localhost"` | machine to ssh too | | [ssh.auth] | `string` | `"password"` | authtype to use | | [ssh.port] | `number` | `22` | port to connect to over ssh | diff --git a/index.js b/index.js index 243dba7..d173a4c 100755 --- a/index.js +++ b/index.js @@ -41,12 +41,6 @@ if (require.main === module) { type: 'string', default: process.env.SSHUSER || '', }, - sshaskuser: { - demand: false, - description: 'ask ssh user from the standard input', - type: 'boolean', - default: process.env.SSHASKUSER || false - }, title: { demand: false, description: 'window title', diff --git a/package.json b/package.json index 9238d81..68d4c5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wetty", - "version": "1.2.4", + "version": "1.2.5", "description": "WeTTY = Web + TTY. Terminal access in browser over http/https", "homepage": "https://github.com/butlerx/wetty", "repository": { diff --git a/src/server/cli/options.ts b/src/server/cli/options.ts index 37d63be..01d4f9c 100644 --- a/src/server/cli/options.ts +++ b/src/server/cli/options.ts @@ -2,7 +2,6 @@ export interface Options { sshhost: string; sshport: number; sshuser: string; - sshaskuser: boolean; sshauth: string; sshkey?: string; sshpass?: string; diff --git a/src/server/cli/parseArgs.ts b/src/server/cli/parseArgs.ts index 24cf68b..792ee14 100644 --- a/src/server/cli/parseArgs.ts +++ b/src/server/cli/parseArgs.ts @@ -8,7 +8,6 @@ export function unWrapArgs( return { ssh: { user: args.sshuser, - askuser: args.sshaskuser, host: args.sshhost, auth: args.sshauth, port: args.sshport, diff --git a/src/server/command/index.ts b/src/server/command/index.ts index 08ec649..91415d3 100644 --- a/src/server/command/index.ts +++ b/src/server/command/index.ts @@ -24,7 +24,7 @@ export default ( conn: { remoteAddress }, }, }: Socket, - { user, askuser, host, port, auth, pass, key }: SSH, + { user, host, port, auth, pass, key }: SSH, command: string, forcessh: boolean ): { args: string[]; user: boolean } => ({ @@ -32,8 +32,7 @@ export default ( ? loginOptions(command, remoteAddress) : sshOptions( urlArgs(referer, { - sshcommand: askuser ? './bin/ssh-with-user' : 'ssh', - host: askuser ? host : address(referer, user, host), + host: address(referer, user, host), port: `${port}`, pass: pass || '', command, @@ -42,7 +41,7 @@ export default ( key ), user: - localhost(host) || + (!forcessh && localhost(host)) || user !== '' || user.includes('@') || address(referer, user, host).includes('@'), diff --git a/src/server/command/ssh.ts b/src/server/command/ssh.ts index 5d05465..ece47e2 100644 --- a/src/server/command/ssh.ts +++ b/src/server/command/ssh.ts @@ -3,13 +3,12 @@ import parseCommand from './parse'; import logger from '../utils/logger'; export default function sshOptions( - { sshcommand, pass, path, command, host, port, auth }: { [s: string]: string }, + { pass, path, command, host, port, auth }: { [s: string]: string }, key?: string ): string[] { const cmd = parseCommand(command, path); - logger.info(`ssh command: ${sshcommand}`); const sshRemoteOptsBase = [ - sshcommand, + 'ssh', host, '-t', '-p', @@ -31,6 +30,7 @@ export default function sshOptions( if (auth === 'none') { sshRemoteOptsBase.splice(sshRemoteOptsBase.indexOf('-o'), 2); } + if (cmd === '') { return sshRemoteOptsBase; } diff --git a/src/server/interfaces.ts b/src/server/interfaces.ts index 3b52d18..16eb4b1 100644 --- a/src/server/interfaces.ts +++ b/src/server/interfaces.ts @@ -1,6 +1,5 @@ export interface SSH { user: string; - askuser: boolean; host: string; auth: string; port: number; diff --git a/src/server/wetty/index.ts b/src/server/wetty/index.ts index a9a44fa..3e44ab9 100644 --- a/src/server/wetty/index.ts +++ b/src/server/wetty/index.ts @@ -13,7 +13,7 @@ import { SSH, SSL, SSLBuffer, Server } from '../interfaces'; * @name startWeTTy */ export default function startWeTTy( - ssh: SSH = { user: '', askuser: false, host: 'localhost', auth: 'password', port: 22 }, + ssh: SSH = { user: '', host: 'localhost', auth: 'password', port: 22 }, serverConf: Server = { base: '/wetty/', port: 3000,