ssh2shell 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +67 -92
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,37 +6,37 @@ Ssh2shell uses [ssh2](https://www.npmjs.org/package/ssh2) to open a ssh shell se
6
6
 
7
7
  Index:
8
8
  ------------
9
- * [Instalation](#installation)
10
- * [Minimal Example](#minimal-example)
11
- * [Host Configuration](#host-configuration)
12
- * [ssh2shell API](#ssh2shell-api)
13
- * [Connecting to a single host](#connecting-to-a-single-host)
14
- * [Authentication](#authentication)
15
- * [Default Cyphers](#default-cyphers)
16
- * [Fingerprint Validation](#fingerprint-validation)
17
- * [Keyboard-interactive](#keyboard-interactive)
18
- * [Trouble shooting](#trouble-shooting)
19
- * [Verbose and Debug](#verbose-and-debug)
20
- * [Notification commands](#notification-commands)
21
- * [Sudo and su Commands](#sudo-and-su-commands)
22
- * [Prompt detection override](#prompt-detection-override)
23
- * [Text regular expression filters](#text-regular-expression-filters)
24
- * [Responding to non-standard command prompts](#responding-to-non-standard-command-prompts)
25
- * [Command Time-out event](#command-time-out-event)
26
- * [Multiple Primary Hosts](#multiple-primary-hosts)
27
- * [Tunnelling nested host objects](#tunnelling-nested-host-objects)
28
- * [Event Handlers](#event-handlers)
29
- * [Bash scripts on the fly](#bash-scripts-on-the-fly)
30
-
31
-
32
- Installation:
9
+ * [Installation](#installation-)
10
+ * [Minimal Example](#minimal-example-)
11
+ * [Host Configuration](#host-configuration-)
12
+ * [ssh2shell API](#ssh2shell-api-)
13
+ * [Usage](#usage-)
14
+ * [Authentication](#authentication-)
15
+ * [Default Algorithms](#default-algorithms-)
16
+ * [Fingerprint Validation](#fingerprint-validation-)
17
+ * [Keyboard-interactive](#keyboard-interactive-)
18
+ * [Troubleshooting](#troubleshooting-)
19
+ * [Verbose and Debug](#verbose-and-debug-)
20
+ * [Notification commands](#notification-commands-)
21
+ * [Sudo and su Commands](#sudo-and-su-commands-)
22
+ * [Prompt detection override](#prompt-detection-override-)
23
+ * [Text regular expression filters](#text-regular-expression-filters-)
24
+ * [Responding to non-standard command prompts](#responding-to-non-standard-command-prompts-)
25
+ * [Command Time-out event](#command-time-out-event-)
26
+ * [Multiple Primary Hosts](#multiple-primary-hosts-)
27
+ * [Tunnelling nested host objects](#tunnelling-nested-host-objects-)
28
+ * [Event Handlers](#event-handlers-)
29
+ * [Bash scripts on the fly](#bash-scripts-on-the-fly-)
30
+
31
+
32
+ [Installation: ^](#)
33
33
  ------------
34
34
  ```
35
35
  npm install ssh2shell
36
36
  ```
37
37
 
38
38
 
39
- Minimal Example:
39
+ [Minimal Example: ^](#)
40
40
  ------------
41
41
  ```javascript
42
42
  //host configuration with connection settings and commands
@@ -60,7 +60,7 @@ SSH.connect(callback);
60
60
  ```
61
61
 
62
62
 
63
- Host Configuration:
63
+ [Host Configuration: ^](#)
64
64
  ------------
65
65
  SSH2Shell requires an object with the following structure:
66
66
  ```javascript
@@ -75,11 +75,19 @@ host = {
75
75
  password: "password",
76
76
  passPhrase: "privateKeyPassphrase",
77
77
  privateKey: require('fs').readFileSync('/path/to/private/key/id_rsa'),
78
- //Optional: ssh2.connect options
79
- //See https://github.com/mscdex/ssh2#client-methods
80
78
 
81
- //Optional: ssh options only for making secondary host ssh connections.
82
- //see http://man.openbsd.org/ssh for definitions of options.
79
+ //Optional: See https://github.com/mscdex/ssh2#client-methods for other ssh2.client.connect(config) options.
80
+ //like
81
+ algorithms: {
82
+ cipher: {},
83
+ compression: {},
84
+ hmac: {},
85
+ kex: {},
86
+ serverhostkey:{}
87
+ },
88
+
89
+ //Optional: Ssh options are only for host to host ssh connections.
90
+ //See http://man.openbsd.org/ssh for definitions of options.
83
91
  ssh: { //Options }
84
92
  },
85
93
  //Optional: Array of host objects for multiple host connections
@@ -118,7 +126,7 @@ host = {
118
126
  }
119
127
  },
120
128
 
121
- //Optional: Trouble shooting options
129
+ //Optional: Troubleshooting options
122
130
  verbose: false, //outputs all received content
123
131
  debug: false, //outputs information about each process step
124
132
 
@@ -217,7 +225,7 @@ host = {
217
225
  variables and the current array of commands for the host. The sshObj.commands array changes with each host connection.
218
226
 
219
227
 
220
- ssh2shell API
228
+ [ssh2shell API: ^](#)
221
229
  -------------
222
230
  SSH2Shell extends events.EventEmitter
223
231
 
@@ -240,11 +248,9 @@ SSH2Shell extends events.EventEmitter
240
248
  * .command is the current command being run until a new prompt is detected and the next command replaces it.
241
249
 
242
250
 
243
- Usage:
244
- ======
245
- Connecting to a single host:
246
- ----------------------------
247
-
251
+ [Usage: ^](#)
252
+ --------
253
+ *Connecting to a single host*
248
254
 
249
255
  *app.js*
250
256
  ```javascript
@@ -274,7 +280,7 @@ SSH.connect(callback);
274
280
  ```
275
281
 
276
282
 
277
- Authentication:
283
+ [Authentication: ^](#)
278
284
  ---------------
279
285
  * Each host authenticates with its own host.server parameters.
280
286
  * When using key authentication you may require a valid pass phrase if your key was created with one.
@@ -284,47 +290,16 @@ Authentication:
284
290
  function...) or host.onKeyboardInteractive() must be defined.
285
291
  * Set the default cyphers and keys.
286
292
 
287
- Default Cyphers:
293
+ [Default Algorithms: ^](#)
288
294
  ---------------
289
- Default Cyphers and Keys used in the initial ssh connection can be redefined by setting the ssh2.connect.algorithms through the host.server.algorithms option.
290
- As with this property all ssh2.connect properties are set in the host.server object.
291
-
292
- *Example:*
293
- ```javascript
294
- var host = {
295
- server: {
296
- host: "<host IP>",
297
- port: "22",
298
- userName: "<username>",
299
- password: "<password>",
300
- hashMethod: "md5", //optional "md5" or "sha1" default is "md5"
301
- //other ssh2.connect options
302
- algorithms: {
303
- kex: [
304
- 'diffie-hellman-group1-sha1',
305
- 'ecdh-sha2-nistp256',
306
- 'ecdh-sha2-nistp384',
307
- 'ecdh-sha2-nistp521',
308
- 'diffie-hellman-group-exchange-sha256',
309
- 'diffie-hellman-group14-sha1'],
310
- cipher: [
311
- 'aes128-ctr',
312
- 'aes192-ctr',
313
- 'aes256-ctr',
314
- 'aes128-gcm',
315
- 'aes128-gcm@openssh.com',
316
- 'aes256-gcm',
317
- 'aes256-gcm@openssh.com',
318
- 'aes256-cbc'
319
- ]
320
- }
321
-
322
- },
323
- ......
324
- }
325
- ```
326
-
327
- Fingerprint Validation:
295
+ See [`ssh2.client.connect(config)`](https://github.com/mscdex/ssh2#client-methods) for a list of the supported algorithms.
296
+ * Ciphers.
297
+ * Compression algorithms.
298
+ * (H)MAC algorithms.
299
+ * Key exchange algorithms.
300
+ * Server host key formats.
301
+
302
+ [Fingerprint Validation: ^](#)
328
303
  ---------------
329
304
  At connection time the hash of the server’s public key can be compared with the hash the client had previously recorded
330
305
  for that server. This stops "man in the middle" attacks where you are redirected to a different server as you connect
@@ -392,14 +367,14 @@ host.server.hashMethod only supports md5 or sha1 according to the current SSH2 d
392
367
  undesired results.__
393
368
 
394
369
 
395
- Keyboard-interactive
370
+ [Keyboard-interactive: ^](#)
396
371
  ----------------------
397
372
  Keyboard-interactive authentication is available when both host.server.tryKeyboard is set to true and the event handler
398
373
  keyboard-interactive is defined as below. The keyboard-interactive event handler can only be used on the first connection.
399
374
 
400
375
  Also see [test/keyboard-interactivetest.js](https://github.com/cmp-202/ssh2shell/blob/master/test/keyboard-interactivetest.js) for the full example
401
376
 
402
- *Defining the event handler:*
377
+ *Defining the event handler*
403
378
  ```javascript
404
379
  //this is required
405
380
  host.server.tryKeyboard = true;
@@ -446,7 +421,7 @@ host = {
446
421
  ```
447
422
 
448
423
 
449
- Trouble shooting:
424
+ [Troubleshooting: ^](#)
450
425
  -----------------
451
426
 
452
427
  * Adding msg command `"msg:Doing something"` to your commands array at key points will help you track the sequence of
@@ -466,7 +441,7 @@ Trouble shooting:
466
441
  (1000 = 1 sec)
467
442
 
468
443
 
469
- Verbose and Debug:
444
+ [Verbose and Debug: ^](#)
470
445
  ------------------
471
446
  * When host.verbose is set to true each command complete raises a msg event outputting the response text.
472
447
  * When host.debug is set to true each process step raises a msg event to help identify what the internal processes were.
@@ -480,7 +455,7 @@ Add your own verbose messages as follows:
480
455
  Add your own debug messages as follows:
481
456
  `if(this.sshObj.debug){this.emit("msg", this.sshObj.server.host + ": eventName");} //where eventName is the text identifying what happened`
482
457
 
483
- Notification commands:
458
+ [Notification commands: ^](#)
484
459
  ----------------------
485
460
  There are two notification commands that are added to the host.commands array but are not run as a command on the host.
486
461
 
@@ -489,7 +464,7 @@ There are two notification commands that are added to the host.commands array bu
489
464
  * The reason for not using echo or printf commands as a normal command is that you see both the command and the message in the sessionText which is pointless when all you want is the message.
490
465
 
491
466
 
492
- Sudo and su Commands:
467
+ [Sudo and su Commands: ^](#)
493
468
  --------------
494
469
  It is possible to use `sudo [command]`, `sudo su`, `su [username]` and `sudo -u [username] -i`.
495
470
  Sudo commands uses the password for the current session and is processed by ssh2shell. Su on the other hand uses the password
@@ -501,7 +476,7 @@ See: [su VS sudo su VS sudo -u -i](http://johnkpaul.tumblr.com/post/19841381351/
501
476
  See: [test/sudosutest.js](https://github.com/cmp-202/ssh2shell/blob/master/test/sudosutest.js) for a working code example.
502
477
 
503
478
 
504
- Prompt detection override:
479
+ [Prompt detection override: ^](#)
505
480
  -------------------------
506
481
  Used to detect different prompts.
507
482
 
@@ -513,7 +488,7 @@ These are optional settings.
513
488
  ```
514
489
 
515
490
 
516
- Text regular expression filters:
491
+ [Text regular expression filters: ^](#)
517
492
  -------------------------------
518
493
  There are two regular expression filters that remove unwanted text from response data.
519
494
 
@@ -528,7 +503,7 @@ host.textColorFilter = "(\[{1}[0-9;]+m{1})"
528
503
  ```
529
504
 
530
505
 
531
- Responding to non-standard command prompts:
506
+ [Responding to non-standard command prompts: ^](#)
532
507
  ----------------------
533
508
  In host.onCommandProcessing event handler the prompt can be detected and a response can be sent via `stream.write("y\n")`.
534
509
 
@@ -568,7 +543,7 @@ __*Note:*
568
543
  If no prompt is detected `commandTimeout` will be raised after the idleTimeOut period.__
569
544
 
570
545
 
571
- Command Time-out event
546
+ [Command Time-out event: ^](#)
572
547
  ---------------
573
548
  When onCommandTimeout event triggers after the host.idleTimeOut is exceeded.
574
549
  This is because there is no new data and no prompt is detected to run the next command.
@@ -637,7 +612,7 @@ SSH.connect();
637
612
  ```
638
613
 
639
614
 
640
- Multiple Primary Hosts:
615
+ [Multiple Primary Hosts: ^](#)
641
616
  -----------------------
642
617
  Multiple hosts can be connected to one after the other as you would connecting to a single host.
643
618
  Each host config is independant of each other but can share thingsa like commands and handlers.
@@ -709,7 +684,7 @@ SSH.connect(callback);
709
684
  ```
710
685
 
711
686
 
712
- Tunnelling nested host objects:
687
+ [Tunnelling nested host objects: ^](#)
713
688
  ---------------------------------
714
689
  `hosts: [ host1, host2]` setting can make multiple host connections possible.
715
690
  Each host config object has its own server settings, commands, command handlers and
@@ -918,7 +893,7 @@ SSH.connect();
918
893
  ```
919
894
 
920
895
 
921
- Event Handlers:
896
+ [Event Handlers: ^](#)
922
897
  ---------------
923
898
  There are a number of event handlers that enable you to add your own code to be run when those events are triggered.
924
899
  Most of these you have already encountered in the host object. You do not have to add event handlers unless you want
@@ -1038,7 +1013,7 @@ ssh2shell.on ("Unpipe", function onUnpipe(source){
1038
1013
  });
1039
1014
  ```
1040
1015
 
1041
- Bash scripts on the fly:
1016
+ [Bash scripts on the fly: ^](#)
1042
1017
  ------------------------
1043
1018
  If the commands you need to run would be better suited to a bash script as part of the process it is possible to generate
1044
1019
  or get the script on the fly. You can echo/printf the script content into a file as a command, ensure it is executable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2shell",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "author": "cmp-202",
5
5
  "description": "A wrapper class for ssh2 to run multiple sequential commands in an SSH shell session, handle command responses, and tunnel through to other hosts using nested host objects",
6
6
  "main": "./lib/ssh2shell.js",