ssh-client-wrapper 3.4.0 → 3.4.1
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 +1 -1
- package/lib/agent.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -222,7 +222,7 @@ If no agent can be used, or `ssh-add` fails, the wrapper silently falls back to
|
|
|
222
222
|
|
|
223
223
|
**Keyless / browser agents:** with no `keyFile`, set `identityAgent` to the socket of an already-populated agent (for example [`bssh-agent`](https://github.com/so5/browser-ssh-agent), which keeps the private key in a browser tab) and the wrapper will authenticate through it.
|
|
224
224
|
|
|
225
|
-
**Windows:** an already-running agent (the OpenSSH Authentication Agent service, or a supplied `identityAgent`) is used, but the wrapper never spawns one; without a reachable agent it falls back to the legacy path.
|
|
225
|
+
**Windows:** an already-running agent (the OpenSSH Authentication Agent service, or a supplied `identityAgent`) is used, but the wrapper never spawns one; without a reachable agent it falls back to the legacy path. The agent of Windows refuses keys with a lifetime, so `agentKeyTTL` is not applied there (the key stays in the agent until it is removed or the agent stops). Git for Windows' ssh/ssh-add can not use the Windows agent service; the wrapper then falls back to the legacy path.
|
|
226
226
|
|
|
227
227
|
## Running the tests
|
|
228
228
|
|
package/lib/agent.js
CHANGED
|
@@ -234,6 +234,18 @@ async function resolvePassphrase(ph) {
|
|
|
234
234
|
return null;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* arguments of ssh-add to add a key
|
|
239
|
+
* the ssh-agent of Windows refuses a key with a lifetime ("agent refused operation"), so -t is not passed there
|
|
240
|
+
* @param {string} keyFile - private key path
|
|
241
|
+
* @param {number} ttl - ssh-add -t lifetime in seconds
|
|
242
|
+
* @param {string} platform - platform name (for tests)
|
|
243
|
+
* @returns {string[]} - arguments
|
|
244
|
+
*/
|
|
245
|
+
function addKeyArgs(keyFile, ttl, platform = process.platform) {
|
|
246
|
+
return platform === "win32" ? [keyFile] : ["-t", String(ttl), keyFile];
|
|
247
|
+
}
|
|
248
|
+
|
|
237
249
|
/**
|
|
238
250
|
* add a key to an agent via `ssh-add`, answering the passphrase prompt from a pty
|
|
239
251
|
* @param {string} sock - agent socket path (or AGENT_DEFAULT)
|
|
@@ -244,7 +256,7 @@ async function resolvePassphrase(ph) {
|
|
|
244
256
|
*/
|
|
245
257
|
function addKey(sock, keyFile, phCallback, ttl) {
|
|
246
258
|
return new Promise((resolve, reject)=>{
|
|
247
|
-
const pty = _internal.spawn(resolveExecutable("ssh-add"),
|
|
259
|
+
const pty = _internal.spawn(resolveExecutable("ssh-add"), addKeyArgs(keyFile, ttl), {
|
|
248
260
|
windowsHide: true,
|
|
249
261
|
env: sockEnv(sock)
|
|
250
262
|
});
|
|
@@ -512,6 +524,7 @@ async function ensureAgentForHost(hostInfo) {
|
|
|
512
524
|
}
|
|
513
525
|
|
|
514
526
|
export {
|
|
527
|
+
addKeyArgs,
|
|
515
528
|
shouldUseAgent,
|
|
516
529
|
canSpawnSharedAgent,
|
|
517
530
|
ensureAgentForHost,
|