ssh-client-wrapper 2.6.1 → 2.8.0
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/docker-compose.yml +1 -1
- package/lib/fork.js +14 -7
- package/lib/sshExec.js +3 -1
- package/lib/util.js +2 -1
- package/package.json +3 -3
- package/run_test_all.sh +2 -2
package/docker-compose.yml
CHANGED
package/lib/fork.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const debug = require("debug")("sshClientWrapper:debug:fork");
|
|
3
3
|
const debugVerbose = require("debug")("sshClientWrapper:verbose:fork");
|
|
4
|
-
const debugSendPty = require("debug")("
|
|
4
|
+
const debugSendPty = require("debug")("sshClientWrapperInsecure:fork_sendpty");
|
|
5
5
|
const { spawn } = require("node-pty");
|
|
6
6
|
|
|
7
|
-
const { rePwPrompt, rePhPrompt, reNewHostPrompt, buff2String, sendPty, watchDogTimer } = require("./util.js");
|
|
7
|
+
const { rePwPrompt, rePhPrompt, reNewHostPrompt, reRemoteHostIdentificationHasChanged, buff2String, sendPty, watchDogTimer } = require("./util.js");
|
|
8
8
|
|
|
9
9
|
const nodePtyOpt = {
|
|
10
10
|
shell: process.platform === "win32" ? process.env.ComSpec : process.env.SHELL,
|
|
@@ -13,7 +13,19 @@ const nodePtyOpt = {
|
|
|
13
13
|
|
|
14
14
|
function sshLoginCallback (output, ptyProcess, pw, ph, logger = debugSendPty) {
|
|
15
15
|
return new Promise((resolve, reject) => {
|
|
16
|
+
if (reRemoteHostIdentificationHasChanged.test(output)) {
|
|
17
|
+
debug("REMOTE HOST IDENTIFICATION HAS CHANGED");
|
|
18
|
+
const rt = /known_hosts:(\d+)/.exec(output);
|
|
19
|
+
const rt2 = /Host key for (.+) has changed and you have requested strict checking./.exec(output);
|
|
20
|
+
const err = new Error("REMOTE HOST IDENTIFICATION HAS CHANGED");
|
|
21
|
+
err.code = "HostKeyError";
|
|
22
|
+
err.output = output;
|
|
23
|
+
err.lineNumber = rt[1] || null;
|
|
24
|
+
err.host = rt2[1] || null;
|
|
25
|
+
reject(err);
|
|
26
|
+
}
|
|
16
27
|
if (reNewHostPrompt.test(output)) {
|
|
28
|
+
debug("get warning about new host and send yes automatically");
|
|
17
29
|
sendPty(ptyProcess, "yes\n", logger, 17);
|
|
18
30
|
resolve();
|
|
19
31
|
}
|
|
@@ -96,11 +108,6 @@ async function fork (hostInfo, cmd, args, timeout, outputCallback, retryableExit
|
|
|
96
108
|
err.retryable = true;
|
|
97
109
|
reject(err);
|
|
98
110
|
}
|
|
99
|
-
if (/muxserver_listen: link mux listener .* Bad file descriptor/.test(output)) {
|
|
100
|
-
ptyProcess.kill();
|
|
101
|
-
const err = new Error("Control socket creation failed");
|
|
102
|
-
reject(err);
|
|
103
|
-
}
|
|
104
111
|
});
|
|
105
112
|
}
|
|
106
113
|
|
package/lib/sshExec.js
CHANGED
|
@@ -3,7 +3,7 @@ const crypto = require("crypto");
|
|
|
3
3
|
const { setTimeout: setTimeoutPromise } = require("timers/promises");
|
|
4
4
|
const debug = require("debug")("sshClientWrapper:debug:sshExec");
|
|
5
5
|
const debugVerbose = require("debug")("sshClientWrapper:verbose:sshExec");
|
|
6
|
-
const debugSendMasterPty = require("debug")("
|
|
6
|
+
const debugSendMasterPty = require("debug")("sshClientWrapperInsecure:sshExec_masterPty");
|
|
7
7
|
const { sendPty, sshCmd, getSshOption, sanityCheck, watchDogTimer } = require("./util.js");
|
|
8
8
|
const { fork, createMasterPty, sshLoginCallback } = require("./fork.js");
|
|
9
9
|
|
|
@@ -143,6 +143,8 @@ async function connect (hostInfo, timeout = 60) {
|
|
|
143
143
|
reject(new Error("Bad port"));
|
|
144
144
|
} else if (/Operation|Connection timed out/.test(output)) {
|
|
145
145
|
reject(new Error("Operation timed out"));
|
|
146
|
+
} else if (/muxserver_listen: link mux listener .* Bad file descriptor/.test(output)) {
|
|
147
|
+
reject(new Error("Control socket creation failed"));
|
|
146
148
|
}
|
|
147
149
|
});
|
|
148
150
|
hostInfo.masterPty.onData((data) => {
|
package/lib/util.js
CHANGED
|
@@ -11,7 +11,7 @@ const acceptableRsyncRetrunCodes = [10, 11, 12, 13, 14];
|
|
|
11
11
|
const rePwPrompt = /password:/;
|
|
12
12
|
const rePhPrompt = /Enter passphrase for key/;
|
|
13
13
|
const reNewHostPrompt = /Are you sure you want to continue connecting/;
|
|
14
|
-
|
|
14
|
+
const reRemoteHostIdentificationHasChanged = /WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! /;
|
|
15
15
|
const Ajv = require("ajv");
|
|
16
16
|
|
|
17
17
|
const ajv = new Ajv({
|
|
@@ -264,6 +264,7 @@ module.exports = {
|
|
|
264
264
|
rePwPrompt,
|
|
265
265
|
rePhPrompt,
|
|
266
266
|
reNewHostPrompt,
|
|
267
|
+
reRemoteHostIdentificationHasChanged,
|
|
267
268
|
buff2String,
|
|
268
269
|
getSshOption,
|
|
269
270
|
sanityCheck,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-client-wrapper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "wrapper library for open ssh client and rsync",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ssh",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"*.js": "eslint --fix"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"ajv": "^8.
|
|
37
|
+
"ajv": "^8.13.0",
|
|
38
38
|
"ajv-keywords": "^5.1.0",
|
|
39
39
|
"debug": "^4.3.4",
|
|
40
|
-
"glob": "^10.3.
|
|
40
|
+
"glob": "^10.3.12",
|
|
41
41
|
"node-pty": "^0.10.1",
|
|
42
42
|
"promise-retry": "^2.0.1"
|
|
43
43
|
},
|
package/run_test_all.sh
CHANGED
|
@@ -11,8 +11,8 @@ docker-compose up testbed -d
|
|
|
11
11
|
export TEST_HOST=localhost
|
|
12
12
|
export TEST_USER=testuser
|
|
13
13
|
export TEST_PW=passw0rd
|
|
14
|
-
export TEST_PORT=
|
|
15
|
-
ssh-keygen -R '[localhost]:
|
|
14
|
+
export TEST_PORT=4100
|
|
15
|
+
ssh-keygen -R '[localhost]:4100'
|
|
16
16
|
|
|
17
17
|
npm run test
|
|
18
18
|
echo local test success
|