ssh2shell 2.0.6 → 2.0.8

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.
package/README.md CHANGED
@@ -6,16 +6,16 @@ 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-)
9
+ * [Installation](#installation-)
10
10
  * [Minimal Example](#minimal-example-)
11
11
  * [Host Configuration](#host-configuration-)
12
12
  * [ssh2shell API](#ssh2shell-api-)
13
13
  * [Usage](#usage-)
14
14
  * [Authentication](#authentication-)
15
- * [Default Cyphers](#default-cyphers-)
15
+ * [Default Algorithms](#default-algorithms-)
16
16
  * [Fingerprint Validation](#fingerprint-validation-)
17
17
  * [Keyboard-interactive](#keyboard-interactive-)
18
- * [Trouble shooting](#trouble-shooting-)
18
+ * [Troubleshooting](#troubleshooting-)
19
19
  * [Verbose and Debug](#verbose-and-debug-)
20
20
  * [Notification commands](#notification-commands-)
21
21
  * [Sudo and su Commands](#sudo-and-su-commands-)
@@ -29,14 +29,14 @@ Index:
29
29
  * [Bash scripts on the fly](#bash-scripts-on-the-fly-)
30
30
 
31
31
 
32
- [Installation: ^](#index)
32
+ [Installation: ^](#)
33
33
  ------------
34
34
  ```
35
35
  npm install ssh2shell
36
36
  ```
37
37
 
38
38
 
39
- [Minimal Example: ^](#index)
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: ^](#index)
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: ^](#index)
228
+ [ssh2shell API: ^](#)
221
229
  -------------
222
230
  SSH2Shell extends events.EventEmitter
223
231
 
@@ -240,7 +248,7 @@ 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: ^](#index)
251
+ [Usage: ^](#)
244
252
  --------
245
253
  *Connecting to a single host*
246
254
 
@@ -272,7 +280,7 @@ SSH.connect(callback);
272
280
  ```
273
281
 
274
282
 
275
- [Authentication: ^](#index)
283
+ [Authentication: ^](#)
276
284
  ---------------
277
285
  * Each host authenticates with its own host.server parameters.
278
286
  * When using key authentication you may require a valid pass phrase if your key was created with one.
@@ -282,47 +290,16 @@ SSH.connect(callback);
282
290
  function...) or host.onKeyboardInteractive() must be defined.
283
291
  * Set the default cyphers and keys.
284
292
 
285
- [Default Cyphers: ^](#index)
293
+ [Default Algorithms: ^](#)
286
294
  ---------------
287
- 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.
288
- As with this property all ssh2.connect properties are set in the host.server object.
289
-
290
- *Example:*
291
- ```javascript
292
- var host = {
293
- server: {
294
- host: "<host IP>",
295
- port: "22",
296
- userName: "<username>",
297
- password: "<password>",
298
- hashMethod: "md5", //optional "md5" or "sha1" default is "md5"
299
- //other ssh2.connect options
300
- algorithms: {
301
- kex: [
302
- 'diffie-hellman-group1-sha1',
303
- 'ecdh-sha2-nistp256',
304
- 'ecdh-sha2-nistp384',
305
- 'ecdh-sha2-nistp521',
306
- 'diffie-hellman-group-exchange-sha256',
307
- 'diffie-hellman-group14-sha1'],
308
- cipher: [
309
- 'aes128-ctr',
310
- 'aes192-ctr',
311
- 'aes256-ctr',
312
- 'aes128-gcm',
313
- 'aes128-gcm@openssh.com',
314
- 'aes256-gcm',
315
- 'aes256-gcm@openssh.com',
316
- 'aes256-cbc'
317
- ]
318
- }
319
-
320
- },
321
- ......
322
- }
323
- ```
324
-
325
- [Fingerprint Validation: ^](#index)
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: ^](#)
326
303
  ---------------
327
304
  At connection time the hash of the server’s public key can be compared with the hash the client had previously recorded
328
305
  for that server. This stops "man in the middle" attacks where you are redirected to a different server as you connect
@@ -390,7 +367,7 @@ host.server.hashMethod only supports md5 or sha1 according to the current SSH2 d
390
367
  undesired results.__
391
368
 
392
369
 
393
- [Keyboard-interactive: ^](#index)
370
+ [Keyboard-interactive: ^](#)
394
371
  ----------------------
395
372
  Keyboard-interactive authentication is available when both host.server.tryKeyboard is set to true and the event handler
396
373
  keyboard-interactive is defined as below. The keyboard-interactive event handler can only be used on the first connection.
@@ -444,7 +421,7 @@ host = {
444
421
  ```
445
422
 
446
423
 
447
- [Trouble shooting: ^](#index)
424
+ [Troubleshooting: ^](#)
448
425
  -----------------
449
426
 
450
427
  * Adding msg command `"msg:Doing something"` to your commands array at key points will help you track the sequence of
@@ -464,7 +441,7 @@ host = {
464
441
  (1000 = 1 sec)
465
442
 
466
443
 
467
- [Verbose and Debug: ^](#index)
444
+ [Verbose and Debug: ^](#)
468
445
  ------------------
469
446
  * When host.verbose is set to true each command complete raises a msg event outputting the response text.
470
447
  * When host.debug is set to true each process step raises a msg event to help identify what the internal processes were.
@@ -478,7 +455,7 @@ Add your own verbose messages as follows:
478
455
  Add your own debug messages as follows:
479
456
  `if(this.sshObj.debug){this.emit("msg", this.sshObj.server.host + ": eventName");} //where eventName is the text identifying what happened`
480
457
 
481
- [Notification commands: ^](#index)
458
+ [Notification commands: ^](#)
482
459
  ----------------------
483
460
  There are two notification commands that are added to the host.commands array but are not run as a command on the host.
484
461
 
@@ -487,7 +464,7 @@ There are two notification commands that are added to the host.commands array bu
487
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.
488
465
 
489
466
 
490
- [Sudo and su Commands: ^](#index)
467
+ [Sudo and su Commands: ^](#)
491
468
  --------------
492
469
  It is possible to use `sudo [command]`, `sudo su`, `su [username]` and `sudo -u [username] -i`.
493
470
  Sudo commands uses the password for the current session and is processed by ssh2shell. Su on the other hand uses the password
@@ -499,7 +476,7 @@ See: [su VS sudo su VS sudo -u -i](http://johnkpaul.tumblr.com/post/19841381351/
499
476
  See: [test/sudosutest.js](https://github.com/cmp-202/ssh2shell/blob/master/test/sudosutest.js) for a working code example.
500
477
 
501
478
 
502
- [Prompt detection override: ^](#index)
479
+ [Prompt detection override: ^](#)
503
480
  -------------------------
504
481
  Used to detect different prompts.
505
482
 
@@ -511,7 +488,7 @@ These are optional settings.
511
488
  ```
512
489
 
513
490
 
514
- [Text regular expression filters: ^](#index)
491
+ [Text regular expression filters: ^](#)
515
492
  -------------------------------
516
493
  There are two regular expression filters that remove unwanted text from response data.
517
494
 
@@ -526,7 +503,7 @@ host.textColorFilter = "(\[{1}[0-9;]+m{1})"
526
503
  ```
527
504
 
528
505
 
529
- [Responding to non-standard command prompts: ^](#index)
506
+ [Responding to non-standard command prompts: ^](#)
530
507
  ----------------------
531
508
  In host.onCommandProcessing event handler the prompt can be detected and a response can be sent via `stream.write("y\n")`.
532
509
 
@@ -566,7 +543,7 @@ __*Note:*
566
543
  If no prompt is detected `commandTimeout` will be raised after the idleTimeOut period.__
567
544
 
568
545
 
569
- [Command Time-out event: ^](#index)
546
+ [Command Time-out event: ^](#)
570
547
  ---------------
571
548
  When onCommandTimeout event triggers after the host.idleTimeOut is exceeded.
572
549
  This is because there is no new data and no prompt is detected to run the next command.
@@ -635,7 +612,7 @@ SSH.connect();
635
612
  ```
636
613
 
637
614
 
638
- [Multiple Primary Hosts: ^](#index)
615
+ [Multiple Primary Hosts: ^](#)
639
616
  -----------------------
640
617
  Multiple hosts can be connected to one after the other as you would connecting to a single host.
641
618
  Each host config is independant of each other but can share thingsa like commands and handlers.
@@ -707,7 +684,7 @@ SSH.connect(callback);
707
684
  ```
708
685
 
709
686
 
710
- [Tunnelling nested host objects: ^](#index)
687
+ [Tunnelling nested host objects: ^](#)
711
688
  ---------------------------------
712
689
  `hosts: [ host1, host2]` setting can make multiple host connections possible.
713
690
  Each host config object has its own server settings, commands, command handlers and
@@ -916,7 +893,7 @@ SSH.connect();
916
893
  ```
917
894
 
918
895
 
919
- [Event Handlers: ^](#index)
896
+ [Event Handlers: ^](#)
920
897
  ---------------
921
898
  There are a number of event handlers that enable you to add your own code to be run when those events are triggered.
922
899
  Most of these you have already encountered in the host object. You do not have to add event handlers unless you want
@@ -1036,7 +1013,7 @@ ssh2shell.on ("Unpipe", function onUnpipe(source){
1036
1013
  });
1037
1014
  ```
1038
1015
 
1039
- [Bash scripts on the fly: ^](#index)
1016
+ [Bash scripts on the fly: ^](#)
1040
1017
  ------------------------
1041
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
1042
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/lib/ssh2shell.js CHANGED
@@ -979,7 +979,8 @@
979
979
  if (_this._hosts.length === 0) {
980
980
  if (typeof _this._callback === 'function') {
981
981
  _this._callback(_this._allSessions);
982
- return _this._removeListeners();
982
+ _this._removeListeners();
983
+ return _this._allSessions;
983
984
  }
984
985
  } else {
985
986
  return _this.emit("newPrimaryHost", _this._nextPrimaryHost(_this._connect));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2shell",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
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",
@@ -607,6 +607,7 @@ class SSH2Shell extends Stream
607
607
  if typeof @_callback == 'function'
608
608
  @_callback @_allSessions
609
609
  @_removeListeners()
610
+ return @_allSessions
610
611
  else
611
612
  @.emit "newPrimaryHost", @_nextPrimaryHost(@_connect)
612
613