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](https://img.shields.io/badge/all_contributors-33-orange.svg?style=flat-square)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
![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

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.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 |

6
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',

2
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": {

1
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;

1
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,

7
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('@'),

6
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;
}

1
src/server/interfaces.ts

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

2
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,

Loading…
Cancel
Save