Browse Source

Removed --sshaskuser option as it's not necessary

pull/226/head
Janos Kasza 5 years ago
parent
commit
7b9adef7e5
  1. 8
      README.md
  2. 9
      bin/ssh-with-user
  3. 1
      docs/API.md
  4. 6
      index.js
  5. 2
      package.json
  6. 1
      src/server/cli/options.ts
  7. 1
      src/server/cli/parseArgs.ts
  8. 7
      src/server/command/index.ts
  9. 6
      src/server/command/ssh.ts
  10. 1
      src/server/interfaces.ts
  11. 2
      src/server/wetty/index.ts

8
README.md

@ -3,7 +3,9 @@
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
![All Contributors](https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square) ![All Contributors](https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square)
<!-- ALL-CONTRIBUTORS-BADGE:END --> <!-- ALL-CONTRIBUTORS-BADGE:END -->
![Version](https://img.shields.io/badge/version-1.1.7-blue.svg?cacheSeconds=2592000) ![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) ![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) [![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 ## Usage
```sh ```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 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` 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 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 `--sshuser` option.
the terminal later (and ignoring `--sshuser`) if using the `--sshaskuser`
option.
Check out the Check out the
[Flags docs](https://github.com/butlerx/wetty/blob/master/docs/flags.md) for a [Flags docs](https://github.com/butlerx/wetty/blob/master/docs/flags.md) for a

9
bin/ssh-with-user

@ -1,9 +0,0 @@
#!/bin/bash
set -e
while [ -z "${username}" ]; do
echo -n "localhost login: "
read username
done
ssh -l "${username}" $@

1
docs/API.md

@ -21,7 +21,6 @@ Starts WeTTy Server
| :------------------------ | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------- | | :------------------------ | --------- | ------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [ssh] | `Object` | | SSH settings | | [ssh] | `Object` | | SSH settings |
| [ssh.user] | `string` | `"''"` | default user for ssh | | [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.host] | `string` | `"localhost"` | machine to ssh too |
| [ssh.auth] | `string` | `"password"` | authtype to use | | [ssh.auth] | `string` | `"password"` | authtype to use |
| [ssh.port] | `number` | `22` | port to connect to over ssh | | [ssh.port] | `number` | `22` | port to connect to over ssh |

6
index.js

@ -41,12 +41,6 @@ if (require.main === module) {
type: 'string', type: 'string',
default: process.env.SSHUSER || '', default: process.env.SSHUSER || '',
}, },
sshaskuser: {
demand: false,
description: 'ask ssh user from the standard input',
type: 'boolean',
default: process.env.SSHASKUSER || false
},
title: { title: {
demand: false, demand: false,
description: 'window title', description: 'window title',

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "wetty", "name": "wetty",
"version": "1.2.4", "version": "1.2.5",
"description": "WeTTY = Web + TTY. Terminal access in browser over http/https", "description": "WeTTY = Web + TTY. Terminal access in browser over http/https",
"homepage": "https://github.com/butlerx/wetty", "homepage": "https://github.com/butlerx/wetty",
"repository": { "repository": {

1
src/server/cli/options.ts

@ -2,7 +2,6 @@ export interface Options {
sshhost: string; sshhost: string;
sshport: number; sshport: number;
sshuser: string; sshuser: string;
sshaskuser: boolean;
sshauth: string; sshauth: string;
sshkey?: string; sshkey?: string;
sshpass?: string; sshpass?: string;

1
src/server/cli/parseArgs.ts

@ -8,7 +8,6 @@ export function unWrapArgs(
return { return {
ssh: { ssh: {
user: args.sshuser, user: args.sshuser,
askuser: args.sshaskuser,
host: args.sshhost, host: args.sshhost,
auth: args.sshauth, auth: args.sshauth,
port: args.sshport, port: args.sshport,

7
src/server/command/index.ts

@ -24,7 +24,7 @@ export default (
conn: { remoteAddress }, conn: { remoteAddress },
}, },
}: Socket, }: Socket,
{ user, askuser, host, port, auth, pass, key }: SSH, { user, host, port, auth, pass, key }: SSH,
command: string, command: string,
forcessh: boolean forcessh: boolean
): { args: string[]; user: boolean } => ({ ): { args: string[]; user: boolean } => ({
@ -32,8 +32,7 @@ export default (
? loginOptions(command, remoteAddress) ? loginOptions(command, remoteAddress)
: sshOptions( : sshOptions(
urlArgs(referer, { urlArgs(referer, {
sshcommand: askuser ? './bin/ssh-with-user' : 'ssh', host: address(referer, user, host),
host: askuser ? host : address(referer, user, host),
port: `${port}`, port: `${port}`,
pass: pass || '', pass: pass || '',
command, command,
@ -42,7 +41,7 @@ export default (
key key
), ),
user: user:
localhost(host) || (!forcessh && localhost(host)) ||
user !== '' || user !== '' ||
user.includes('@') || user.includes('@') ||
address(referer, user, host).includes('@'), address(referer, user, host).includes('@'),

6
src/server/command/ssh.ts

@ -3,13 +3,12 @@ import parseCommand from './parse';
import logger from '../utils/logger'; import logger from '../utils/logger';
export default function sshOptions( 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 key?: string
): string[] { ): string[] {
const cmd = parseCommand(command, path); const cmd = parseCommand(command, path);
logger.info(`ssh command: ${sshcommand}`);
const sshRemoteOptsBase = [ const sshRemoteOptsBase = [
sshcommand, 'ssh',
host, host,
'-t', '-t',
'-p', '-p',
@ -31,6 +30,7 @@ export default function sshOptions(
if (auth === 'none') { if (auth === 'none') {
sshRemoteOptsBase.splice(sshRemoteOptsBase.indexOf('-o'), 2); sshRemoteOptsBase.splice(sshRemoteOptsBase.indexOf('-o'), 2);
} }
if (cmd === '') { if (cmd === '') {
return sshRemoteOptsBase; return sshRemoteOptsBase;
} }

1
src/server/interfaces.ts

@ -1,6 +1,5 @@
export interface SSH { export interface SSH {
user: string; user: string;
askuser: boolean;
host: string; host: string;
auth: string; auth: string;
port: number; port: number;

2
src/server/wetty/index.ts

@ -13,7 +13,7 @@ import { SSH, SSL, SSLBuffer, Server } from '../interfaces';
* @name startWeTTy * @name startWeTTy
*/ */
export default function 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 = { serverConf: Server = {
base: '/wetty/', base: '/wetty/',
port: 3000, port: 3000,

Loading…
Cancel
Save