@zukhruf/ssh 0.0.0-stage → 0.8.29
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/LICENSE +21 -0
- package/README.md +1123 -2
- package/dist/address.d.ts +8 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.js +15 -0
- package/dist/address.js.map +1 -0
- package/dist/agent.d.ts +35 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +288 -0
- package/dist/agent.js.map +1 -0
- package/dist/channel-stream.d.ts +16 -0
- package/dist/channel-stream.d.ts.map +1 -0
- package/dist/channel-stream.js +102 -0
- package/dist/channel-stream.js.map +1 -0
- package/dist/client.d.ts +114 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +587 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +255 -0
- package/dist/config.js.map +1 -0
- package/dist/control/control-client.d.ts +12 -0
- package/dist/control/control-client.d.ts.map +1 -0
- package/dist/control/control-client.js +156 -0
- package/dist/control/control-client.js.map +1 -0
- package/dist/control/control-master.d.ts +12 -0
- package/dist/control/control-master.d.ts.map +1 -0
- package/dist/control/control-master.js +101 -0
- package/dist/control/control-master.js.map +1 -0
- package/dist/control/control-stream.d.ts +29 -0
- package/dist/control/control-stream.d.ts.map +1 -0
- package/dist/control/control-stream.js +54 -0
- package/dist/control/control-stream.js.map +1 -0
- package/dist/control/messages.d.ts +38 -0
- package/dist/control/messages.d.ts.map +1 -0
- package/dist/control/messages.js +92 -0
- package/dist/control/messages.js.map +1 -0
- package/dist/control/serve-dial.d.ts +11 -0
- package/dist/control/serve-dial.d.ts.map +1 -0
- package/dist/control/serve-dial.js +47 -0
- package/dist/control/serve-dial.js.map +1 -0
- package/dist/control/serve-session.d.ts +11 -0
- package/dist/control/serve-session.d.ts.map +1 -0
- package/dist/control/serve-session.js +78 -0
- package/dist/control/serve-session.js.map +1 -0
- package/dist/control/wire.d.ts +41 -0
- package/dist/control/wire.d.ts.map +1 -0
- package/dist/control/wire.js +100 -0
- package/dist/control/wire.js.map +1 -0
- package/dist/control.d.ts +4 -0
- package/dist/control.d.ts.map +1 -0
- package/dist/control.js +4 -0
- package/dist/control.js.map +1 -0
- package/dist/dial-route.d.ts +14 -0
- package/dist/dial-route.d.ts.map +1 -0
- package/dist/dial-route.js +87 -0
- package/dist/dial-route.js.map +1 -0
- package/dist/host-key-algorithms.d.ts +7 -0
- package/dist/host-key-algorithms.d.ts.map +1 -0
- package/dist/host-key-algorithms.js +16 -0
- package/dist/host-key-algorithms.js.map +1 -0
- package/dist/host-key-policy.d.ts +22 -0
- package/dist/host-key-policy.d.ts.map +1 -0
- package/dist/host-key-policy.js +72 -0
- package/dist/host-key-policy.js.map +1 -0
- package/dist/identities.d.ts +18 -0
- package/dist/identities.d.ts.map +1 -0
- package/dist/identities.js +81 -0
- package/dist/identities.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/knownhosts.d.ts +33 -0
- package/dist/knownhosts.d.ts.map +1 -0
- package/dist/knownhosts.js +241 -0
- package/dist/knownhosts.js.map +1 -0
- package/dist/match-pattern.d.ts +3 -0
- package/dist/match-pattern.d.ts.map +1 -0
- package/dist/match-pattern.js +18 -0
- package/dist/match-pattern.js.map +1 -0
- package/dist/private-key.d.ts +42 -0
- package/dist/private-key.d.ts.map +1 -0
- package/dist/private-key.js +100 -0
- package/dist/private-key.js.map +1 -0
- package/dist/prompt.d.ts +6 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +2 -0
- package/dist/prompt.js.map +1 -0
- package/dist/proxy-command.d.ts +33 -0
- package/dist/proxy-command.d.ts.map +1 -0
- package/dist/proxy-command.js +121 -0
- package/dist/proxy-command.js.map +1 -0
- package/dist/proxy-jump.d.ts +19 -0
- package/dist/proxy-jump.d.ts.map +1 -0
- package/dist/proxy-jump.js +63 -0
- package/dist/proxy-jump.js.map +1 -0
- package/dist/public-key.d.ts +22 -0
- package/dist/public-key.d.ts.map +1 -0
- package/dist/public-key.js +102 -0
- package/dist/public-key.js.map +1 -0
- package/dist/remote-listener.d.ts +14 -0
- package/dist/remote-listener.d.ts.map +1 -0
- package/dist/remote-listener.js +39 -0
- package/dist/remote-listener.js.map +1 -0
- package/dist/server-alive-check.d.ts +36 -0
- package/dist/server-alive-check.d.ts.map +1 -0
- package/dist/server-alive-check.js +103 -0
- package/dist/server-alive-check.js.map +1 -0
- package/dist/server.d.ts +114 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +460 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +97 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +193 -0
- package/dist/session.js.map +1 -0
- package/dist/ssh-g.d.ts +19 -0
- package/dist/ssh-g.d.ts.map +1 -0
- package/dist/ssh-g.js +67 -0
- package/dist/ssh-g.js.map +1 -0
- package/dist/ssh2-agent-forwarding.d.ts +51 -0
- package/dist/ssh2-agent-forwarding.d.ts.map +1 -0
- package/dist/ssh2-agent-forwarding.js +56 -0
- package/dist/ssh2-agent-forwarding.js.map +1 -0
- package/dist/ssh2-channel-open-failure.d.ts +28 -0
- package/dist/ssh2-channel-open-failure.d.ts.map +1 -0
- package/dist/ssh2-channel-open-failure.js +35 -0
- package/dist/ssh2-channel-open-failure.js.map +1 -0
- package/dist/ssh2-keepalive-request.d.ts +31 -0
- package/dist/ssh2-keepalive-request.d.ts.map +1 -0
- package/dist/ssh2-keepalive-request.js +6 -0
- package/dist/ssh2-keepalive-request.js.map +1 -0
- package/dist/ssh2-server-channel.d.ts +63 -0
- package/dist/ssh2-server-channel.d.ts.map +1 -0
- package/dist/ssh2-server-channel.js +309 -0
- package/dist/ssh2-server-channel.js.map +1 -0
- package/package.json +75 -4
package/dist/session.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { PassThrough, } from 'node:stream';
|
|
2
|
+
import { finished } from 'node:stream/promises';
|
|
3
|
+
import { Future } from '@zukhruf/async';
|
|
4
|
+
const bridge = {
|
|
5
|
+
construct: () => {
|
|
6
|
+
throw new Error('ssh: the Session class has not loaded');
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
/** A session that opens its channel with `open`. Not in the API: Client.newSession calls it. */
|
|
10
|
+
export function createSession(open) {
|
|
11
|
+
return bridge.construct(open);
|
|
12
|
+
}
|
|
13
|
+
const unstarted = {
|
|
14
|
+
configure() { },
|
|
15
|
+
channel: () => Promise.reject(new Error('ssh: the session has not started')),
|
|
16
|
+
};
|
|
17
|
+
class Started {
|
|
18
|
+
opened = new Future();
|
|
19
|
+
configure() {
|
|
20
|
+
throw new Error('ssh: the session has already started');
|
|
21
|
+
}
|
|
22
|
+
channel() {
|
|
23
|
+
return this.opened.wait();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** One command or shell on the remote host. Go's ssh.Session. */
|
|
27
|
+
export class Session {
|
|
28
|
+
static {
|
|
29
|
+
bridge.construct = (open) => new Session(open);
|
|
30
|
+
}
|
|
31
|
+
/** Its end sends SSH_MSG_CHANNEL_EOF. */
|
|
32
|
+
stdin;
|
|
33
|
+
stdout;
|
|
34
|
+
/** SSH_MSG_CHANNEL_EXTENDED_DATA, type 1. */
|
|
35
|
+
stderr;
|
|
36
|
+
#stdin = new PassThrough();
|
|
37
|
+
#stdout = new PassThrough();
|
|
38
|
+
#stderr = new PassThrough();
|
|
39
|
+
#open;
|
|
40
|
+
#env = {};
|
|
41
|
+
#ptys = [];
|
|
42
|
+
#exit = new Future();
|
|
43
|
+
#phase = unstarted;
|
|
44
|
+
constructor(open) {
|
|
45
|
+
this.#open = open;
|
|
46
|
+
this.stdin = this.#stdin;
|
|
47
|
+
this.stdout = this.#stdout;
|
|
48
|
+
this.stderr = this.#stderr;
|
|
49
|
+
}
|
|
50
|
+
/** An env request, sent at start after the variables of ClientConfig.sessionEnv, with no reply wanted, as OpenSSH sends it: a server that refuses the variable ignores it. Go's Setenv wants a reply and returns an error on a refusal. */
|
|
51
|
+
setenv(name, value) {
|
|
52
|
+
this.#phase.configure();
|
|
53
|
+
this.#env[name] = value;
|
|
54
|
+
}
|
|
55
|
+
/** Sent at start. A refusal rejects start() or shell(). Go's RequestPty. */
|
|
56
|
+
requestPty(term, size, modes) {
|
|
57
|
+
this.#phase.configure();
|
|
58
|
+
this.#ptys.push({ term, size, modes });
|
|
59
|
+
}
|
|
60
|
+
/** Resolves when the server accepted the command. Go's Start. */
|
|
61
|
+
async start(command) {
|
|
62
|
+
await this.#begin(command);
|
|
63
|
+
}
|
|
64
|
+
/** A login shell. Go's Shell. */
|
|
65
|
+
async shell() {
|
|
66
|
+
await this.#begin(undefined);
|
|
67
|
+
}
|
|
68
|
+
/** Resolves at exit status 0. Rejects with ExitError or ExitMissingError. Go's Wait. An output stream that nothing reads is discarded, as Go's Session discards a nil Stdout or Stderr. */
|
|
69
|
+
async wait() {
|
|
70
|
+
await this.#phase.channel();
|
|
71
|
+
this.#discardUnread();
|
|
72
|
+
return this.#exit.wait();
|
|
73
|
+
}
|
|
74
|
+
/** start(), then wait(). Go's Run. */
|
|
75
|
+
async run(command) {
|
|
76
|
+
await this.start(command);
|
|
77
|
+
await this.wait();
|
|
78
|
+
}
|
|
79
|
+
/** run(), and stdout. Go's Output. */
|
|
80
|
+
async output(command) {
|
|
81
|
+
return this.#collect(command, [this.#stdout]);
|
|
82
|
+
}
|
|
83
|
+
/** run(), and stdout and stderr in the order they came. Go's CombinedOutput. */
|
|
84
|
+
async combinedOutput(command) {
|
|
85
|
+
return this.#collect(command, [this.#stdout, this.#stderr]);
|
|
86
|
+
}
|
|
87
|
+
/** Go's WindowChange. */
|
|
88
|
+
async windowChange(size) {
|
|
89
|
+
(await this.#phase.channel()).windowChange(size);
|
|
90
|
+
}
|
|
91
|
+
/** Go's Signal. */
|
|
92
|
+
async signal(name) {
|
|
93
|
+
(await this.#phase.channel()).signal(name);
|
|
94
|
+
}
|
|
95
|
+
/** SSH_MSG_CHANNEL_CLOSE. sshd does not end a command without a pty on a close. It resolves when the message is sent, as Go's Session.Close returns: sshd answers the close only after the command ended. */
|
|
96
|
+
async close() {
|
|
97
|
+
const channel = await this.#phase.channel().catch(() => undefined);
|
|
98
|
+
if (channel === undefined)
|
|
99
|
+
return;
|
|
100
|
+
this.#discardUnread();
|
|
101
|
+
channel.close();
|
|
102
|
+
}
|
|
103
|
+
[Symbol.asyncDispose]() {
|
|
104
|
+
return this.close();
|
|
105
|
+
}
|
|
106
|
+
async #collect(command, streams) {
|
|
107
|
+
const chunks = [];
|
|
108
|
+
for (const stream of streams) {
|
|
109
|
+
stream.on('data', (chunk) => chunks.push(chunk));
|
|
110
|
+
}
|
|
111
|
+
await this.run(command);
|
|
112
|
+
await Promise.all(streams.map((stream) => finished(stream)));
|
|
113
|
+
return Buffer.concat(chunks);
|
|
114
|
+
}
|
|
115
|
+
// ssh2 closes a channel only after its data was read (onCHANNEL_CLOSE in
|
|
116
|
+
// utils.js), so a stream that nothing reads would hold the close forever.
|
|
117
|
+
#discardUnread() {
|
|
118
|
+
for (const stream of [this.#stdout, this.#stderr]) {
|
|
119
|
+
if (stream.readableFlowing === null)
|
|
120
|
+
stream.resume();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async #begin(command) {
|
|
124
|
+
this.#phase.configure();
|
|
125
|
+
const started = new Started();
|
|
126
|
+
this.#phase = started;
|
|
127
|
+
// ssh2's exec and shell throw at once on a closed connection.
|
|
128
|
+
const channel = await Promise.try(() => this.#open({ command, env: this.#env, pty: this.#ptys.at(-1) })).catch((error) => {
|
|
129
|
+
started.opened.reject(error);
|
|
130
|
+
throw error;
|
|
131
|
+
});
|
|
132
|
+
this.#stdin.pipe(channel.stream);
|
|
133
|
+
// A write that the channel cannot take fails stdin, as EPIPE fails the
|
|
134
|
+
// stdin of a child process.
|
|
135
|
+
channel.stream.once('error', (error) => this.#stdin.destroy(error));
|
|
136
|
+
channel.stream.pipe(this.#stdout);
|
|
137
|
+
channel.stderr.pipe(this.#stderr);
|
|
138
|
+
channel.onClose((exit, connectionError) => {
|
|
139
|
+
if (exit === undefined) {
|
|
140
|
+
this.#exit.reject(new ExitMissingError(connectionError && { cause: connectionError }));
|
|
141
|
+
}
|
|
142
|
+
else if (exit.kind === 'status' && exit.exitStatus === 0) {
|
|
143
|
+
this.#exit.resolve();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
this.#exit.reject(new ExitError(exit));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
started.opened.resolve(channel);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const signalNames = [
|
|
153
|
+
'ABRT',
|
|
154
|
+
'ALRM',
|
|
155
|
+
'FPE',
|
|
156
|
+
'HUP',
|
|
157
|
+
'ILL',
|
|
158
|
+
'INT',
|
|
159
|
+
'KILL',
|
|
160
|
+
'PIPE',
|
|
161
|
+
'QUIT',
|
|
162
|
+
'SEGV',
|
|
163
|
+
'TERM',
|
|
164
|
+
'USR1',
|
|
165
|
+
'USR2',
|
|
166
|
+
];
|
|
167
|
+
export function isSignalName(value) {
|
|
168
|
+
return signalNames.some((name) => name === value);
|
|
169
|
+
}
|
|
170
|
+
/** A signal name of RFC 4254 §6.10, or a vendor name with an @, such as sshd's SIG@openssh.com (sig2name in OpenSSH's session.c). */
|
|
171
|
+
export function isSignalOrVendorName(value) {
|
|
172
|
+
return (isSignalName(value) || (typeof value === 'string' && value.includes('@')));
|
|
173
|
+
}
|
|
174
|
+
/** Go's ExitError. */
|
|
175
|
+
export class ExitError extends Error {
|
|
176
|
+
exit;
|
|
177
|
+
constructor(exit) {
|
|
178
|
+
super(exit.kind === 'status'
|
|
179
|
+
? `ssh: the command exited with status ${exit.exitStatus}`
|
|
180
|
+
: `ssh: the command ended on signal ${exit.signal}`);
|
|
181
|
+
this.name = 'ExitError';
|
|
182
|
+
this.exit = exit;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/** Go's ExitMissingError. */
|
|
186
|
+
export class ExitMissingError extends Error {
|
|
187
|
+
/** `cause` is the error that ended the connection, when the channel closed with it. */
|
|
188
|
+
constructor(options) {
|
|
189
|
+
super('ssh: the session ended with no exit status or exit signal', options);
|
|
190
|
+
this.name = 'ExitMissingError';
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAmCxC,MAAM,MAAM,GAAkD;IAC5D,SAAS,EAAE,GAAG,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;CACF,CAAC;AAEF,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,IAAiB;IAC7C,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AASD,MAAM,SAAS,GAAU;IACvB,SAAS,KAAI,CAAC;IACd,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;CAC7E,CAAC;AAEF,MAAM,OAAO;IACF,MAAM,GAAG,IAAI,MAAM,EAAkB,CAAC;IAE/C,SAAS;QACP,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,iEAAiE;AACjE,MAAM,OAAO,OAAO;IAClB;QACE,MAAM,CAAC,SAAS,GAAG,CAAC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ables of the caller's environment. ssh -G runs with them as its whole environment. */
|
|
2
|
+
export type Environment = Readonly<Record<string, string | undefined>>;
|
|
3
|
+
/** The settings that ssh -G prints: one `key value` line each, many lines for a setting with many values. */
|
|
4
|
+
export declare class Settings {
|
|
5
|
+
#private;
|
|
6
|
+
private constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Runs `ssh -G <args> -- <destination>` with `environment`. A non-zero exit
|
|
9
|
+
* rejects with ssh's standard error, and a cause whose `code` is the exit
|
|
10
|
+
* code; a warning on standard error with exit 0 is ignored. The signal
|
|
11
|
+
* stops ssh.
|
|
12
|
+
*/
|
|
13
|
+
static resolve(args: readonly string[], destination: string, environment: Environment, signal: AbortSignal | undefined): Promise<Settings>;
|
|
14
|
+
get(key: string): string | undefined;
|
|
15
|
+
getAll(key: string): readonly string[];
|
|
16
|
+
/** The value of a key that ssh -G prints for every host. */
|
|
17
|
+
required(key: string): string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ssh-g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-g.d.ts","sourceRoot":"","sources":["../src/ssh-g.ts"],"names":[],"mappings":"AAGA,iGAAiG;AACjG,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAIvE,6GAA6G;AAC7G,qBAAa,QAAQ;;IAGnB,OAAO;IAIP;;;;;OAKG;WACU,OAAO,CAClB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,QAAQ,CAAC;IA2BpB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE;IAItC,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAO9B"}
|
package/dist/ssh-g.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
const run = promisify(execFile);
|
|
4
|
+
/** The settings that ssh -G prints: one `key value` line each, many lines for a setting with many values. */
|
|
5
|
+
export class Settings {
|
|
6
|
+
#values;
|
|
7
|
+
constructor(values) {
|
|
8
|
+
this.#values = values;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Runs `ssh -G <args> -- <destination>` with `environment`. A non-zero exit
|
|
12
|
+
* rejects with ssh's standard error, and a cause whose `code` is the exit
|
|
13
|
+
* code; a warning on standard error with exit 0 is ignored. The signal
|
|
14
|
+
* stops ssh.
|
|
15
|
+
*/
|
|
16
|
+
static async resolve(args, destination, environment, signal) {
|
|
17
|
+
let stdout;
|
|
18
|
+
try {
|
|
19
|
+
({ stdout } = await run('ssh', ['-G', ...args, '--', destination], {
|
|
20
|
+
env: environment,
|
|
21
|
+
encoding: 'utf8',
|
|
22
|
+
...(signal === undefined ? {} : { signal }),
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (signal?.aborted)
|
|
27
|
+
throw signal.reason;
|
|
28
|
+
if (isExit(error)) {
|
|
29
|
+
throw new Error(error.stderr.trim(), { cause: error });
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
const values = new Map();
|
|
34
|
+
for (const line of stdout.split('\n')) {
|
|
35
|
+
const space = line.indexOf(' ');
|
|
36
|
+
if (space === -1)
|
|
37
|
+
continue;
|
|
38
|
+
const key = line.slice(0, space);
|
|
39
|
+
const all = values.get(key) ?? [];
|
|
40
|
+
all.push(line.slice(space + 1));
|
|
41
|
+
values.set(key, all);
|
|
42
|
+
}
|
|
43
|
+
return new Settings(values);
|
|
44
|
+
}
|
|
45
|
+
get(key) {
|
|
46
|
+
return this.#values.get(key)?.[0];
|
|
47
|
+
}
|
|
48
|
+
getAll(key) {
|
|
49
|
+
return this.#values.get(key) ?? [];
|
|
50
|
+
}
|
|
51
|
+
/** The value of a key that ssh -G prints for every host. */
|
|
52
|
+
required(key) {
|
|
53
|
+
const value = this.get(key);
|
|
54
|
+
if (value === undefined) {
|
|
55
|
+
throw new Error(`ssh -G printed no ${key}`);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isExit(error) {
|
|
61
|
+
return (Error.isError(error) &&
|
|
62
|
+
'code' in error &&
|
|
63
|
+
typeof error.code === 'number' &&
|
|
64
|
+
'stderr' in error &&
|
|
65
|
+
typeof error.stderr === 'string');
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=ssh-g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-g.js","sourceRoot":"","sources":["../src/ssh-g.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAKtC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAEhC,6GAA6G;AAC7G,MAAM,OAAO,QAAQ;IACV,OAAO,CAAyC;IAEzD,YAAoB,MAA8C;QAChE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,IAAuB,EACvB,WAAmB,EACnB,WAAwB,EACxB,MAA+B;QAE/B,IAAI,MAAc,CAAC;QACnB,IAAI,CAAC;YACH,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE;gBACjE,GAAG,EAAE,WAAW;gBAChB,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AW;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,4DAA4D;IAC5D,QAAQ,CAAC,GAAW;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,SAAS,MAAM,CACb,KAAc;IAEd,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,MAAM,IAAI,KAAK;QACf,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,QAAQ,IAAI,KAAK;QACjB,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every use of the internals of ssh2 1.17.0 for agent forwarding by the
|
|
3
|
+
* client. ssh2 is pinned exactly; re-check each line below on a version bump.
|
|
4
|
+
*
|
|
5
|
+
* Why: OpenSSH's ForwardAgent yes sends auth-agent-req@openssh.com on each
|
|
6
|
+
* session with no reply wanted (ssh.c:2204 of OpenSSH 10.0p1). sshd grants
|
|
7
|
+
* only the first request of a connection, answers each later one with a
|
|
8
|
+
* failure, and gives the one socket to every session (session.c:2166-2185,
|
|
9
|
+
* :1085-1087). ssh2 instead sends the request with a reply wanted, so a
|
|
10
|
+
* refusal would reject the session, and only on the first session of a
|
|
11
|
+
* client. This module sends the request itself, and leaves ssh2's request
|
|
12
|
+
* off (no `agentForward`).
|
|
13
|
+
*
|
|
14
|
+
* - lib/client.js:219-224, :254: `agent` must be a BaseAgent
|
|
15
|
+
* (lib/agent.js:1110), and becomes `_agent`.
|
|
16
|
+
* - lib/client.js:1995-2006: an auth-agent@openssh.com channel is accepted
|
|
17
|
+
* only while `_agentFwdEnabled` is true, and is piped both ways to the
|
|
18
|
+
* stream of `_agent.getStream`. reqAgentFwd (:1794-1823), the only other
|
|
19
|
+
* reader, runs only with `agentForward`.
|
|
20
|
+
* - lib/client.js:249, :534-563, :1643-1659: `_chanMgr` (lib/utils.js:124-
|
|
21
|
+
* 165, ChannelManager) holds the callback of each channel that the client
|
|
22
|
+
* opens, with its `type` ('session' for exec and shell). The confirmation
|
|
23
|
+
* of the server calls it with no error and the Channel, whose
|
|
24
|
+
* `outgoing.id` is the channel number of the server; exec and shell then
|
|
25
|
+
* send their requests in the same tick (:1192-1308).
|
|
26
|
+
* - lib/protocol/Protocol.js:1446-1462: `_protocol.openssh_agentForward(id,
|
|
27
|
+
* wantReply)`.
|
|
28
|
+
*/
|
|
29
|
+
import type { Duplex } from 'node:stream';
|
|
30
|
+
import ssh2, { type ConnectConfig } from 'ssh2';
|
|
31
|
+
declare module 'ssh2' {
|
|
32
|
+
interface Client {
|
|
33
|
+
_agentFwdEnabled: boolean;
|
|
34
|
+
readonly _chanMgr: {
|
|
35
|
+
add(value: unknown): number;
|
|
36
|
+
};
|
|
37
|
+
readonly _protocol: ClientProtocol;
|
|
38
|
+
}
|
|
39
|
+
interface ClientProtocol {
|
|
40
|
+
openssh_agentForward(channel: number, wantReply: boolean): void;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The option of `connect` that lets ssh2 join each auth-agent@openssh.com channel to a new connection of `open`. */
|
|
44
|
+
export declare function agentForwardingOptions(open: () => Promise<Duplex>): Pick<ConnectConfig, 'agent'>;
|
|
45
|
+
/** Agent forwarding on a connection; stop() turns it off for each later session and refuses each later agent channel. */
|
|
46
|
+
export interface AgentForwarding {
|
|
47
|
+
stop(): void;
|
|
48
|
+
}
|
|
49
|
+
/** Makes each session of the connection ask for agent forwarding first, with no reply wanted, and accepts the agent channels. Call it after `connect`, which creates the channel manager. */
|
|
50
|
+
export declare function requestAgentForwardingOnEachSession(connection: ssh2.Client): AgentForwarding;
|
|
51
|
+
//# sourceMappingURL=ssh2-agent-forwarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-agent-forwarding.d.ts","sourceRoot":"","sources":["../src/ssh2-agent-forwarding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,IAAI,EAAE,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAOhD,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,MAAM;QACd,gBAAgB,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,QAAQ,EAAE;YAAE,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAA;SAAE,CAAC;QACnD,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;KACpC;IACD,UAAU,cAAc;QACtB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;KACjE;CACF;AAED,qHAAqH;AACrH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAC1B,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAE9B;AAED,yHAAyH;AACzH,MAAM,WAAW,eAAe;IAC9B,IAAI,IAAI,IAAI,CAAC;CACd;AAED,6LAA6L;AAC7L,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,IAAI,CAAC,MAAM,GACtB,eAAe,CAoBjB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ssh2, {} from 'ssh2';
|
|
2
|
+
/** The option of `connect` that lets ssh2 join each auth-agent@openssh.com channel to a new connection of `open`. */
|
|
3
|
+
export function agentForwardingOptions(open) {
|
|
4
|
+
return { agent: new ForwardedAgent(open) };
|
|
5
|
+
}
|
|
6
|
+
/** Makes each session of the connection ask for agent forwarding first, with no reply wanted, and accepts the agent channels. Call it after `connect`, which creates the channel manager. */
|
|
7
|
+
export function requestAgentForwardingOnEachSession(connection) {
|
|
8
|
+
connection._agentFwdEnabled = true;
|
|
9
|
+
const manager = connection._chanMgr;
|
|
10
|
+
const add = manager.add.bind(manager);
|
|
11
|
+
manager.add = (value) => {
|
|
12
|
+
if (!isSessionCallback(value))
|
|
13
|
+
return add(value);
|
|
14
|
+
const opened = (error, channel) => {
|
|
15
|
+
if (error === undefined) {
|
|
16
|
+
connection._protocol.openssh_agentForward(channel.outgoing.id, false);
|
|
17
|
+
}
|
|
18
|
+
value(error, channel);
|
|
19
|
+
};
|
|
20
|
+
return add(Object.assign(opened, { type: value.type }));
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
stop() {
|
|
24
|
+
manager.add = add;
|
|
25
|
+
connection._agentFwdEnabled = false;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function isSessionCallback(value) {
|
|
30
|
+
return (typeof value === 'function' && 'type' in value && value.type === 'session');
|
|
31
|
+
}
|
|
32
|
+
// ssh2 asks this agent only for a stream; the signers of the auth methods go
|
|
33
|
+
// to ssh2 through their own agent.
|
|
34
|
+
class ForwardedAgent extends ssh2.BaseAgent {
|
|
35
|
+
#open;
|
|
36
|
+
constructor(open) {
|
|
37
|
+
super();
|
|
38
|
+
this.#open = open;
|
|
39
|
+
}
|
|
40
|
+
getIdentities(callback) {
|
|
41
|
+
callback(new Error('ssh: the forwarded agent lists no keys'));
|
|
42
|
+
}
|
|
43
|
+
sign(_key, _data, options, callback) {
|
|
44
|
+
const done = typeof options === 'function' ? options : callback;
|
|
45
|
+
done?.(new Error('ssh: the forwarded agent signs nothing'));
|
|
46
|
+
}
|
|
47
|
+
// ssh2 rejects the channel at an error, and pipes the channel and the
|
|
48
|
+
// stream both ways; it listens for no error of the stream.
|
|
49
|
+
getStream(callback) {
|
|
50
|
+
this.#open().then((stream) => {
|
|
51
|
+
stream.on('error', () => stream.destroy());
|
|
52
|
+
callback(undefined, stream);
|
|
53
|
+
}, (error) => callback(Error.isError(error) ? error : new Error(String(error))));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ssh2-agent-forwarding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-agent-forwarding.js","sourceRoot":"","sources":["../src/ssh2-agent-forwarding.ts"],"names":[],"mappings":"AA8BA,OAAO,IAAI,EAAE,EAAsB,MAAM,MAAM,CAAC;AAkBhD,qHAAqH;AACrH,MAAM,UAAU,sBAAsB,CACpC,IAA2B;IAE3B,OAAO,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;AAC7C,CAAC;AAOD,6LAA6L;AAC7L,MAAM,UAAU,mCAAmC,CACjD,UAAuB;IAEvB,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACnC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC;IACpC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,GAAG,CAAC,KAAc,EAAU,EAAE;QACvC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,MAAM,GAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAChD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YACxE,CAAC;YACD,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACxB,CAAC,CAAC;QACF,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,KA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AC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACpE,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every use of the internals of ssh2 1.17.0 for a channel open that the
|
|
3
|
+
* server refused. ssh2 is pinned exactly; re-check each line below on a
|
|
4
|
+
* version bump.
|
|
5
|
+
*
|
|
6
|
+
* Why: @types/ssh2 types the error of a channel open as a plain Error, and
|
|
7
|
+
* ssh2 documents no field for the reason code of SSH_MSG_CHANNEL_OPEN_FAILURE
|
|
8
|
+
* (RFC 4254 §5.1). OpenChannelError gives that code.
|
|
9
|
+
*
|
|
10
|
+
* - lib/protocol/handlers.misc.js:855-881: SSH_MSG_CHANNEL_OPEN_FAILURE is
|
|
11
|
+
* parsed into the recipient, the reason code (uint32) and the description.
|
|
12
|
+
* - lib/client.js:564-571: the client hands `{ reason, description }` to
|
|
13
|
+
* onChannelOpenFailure, for each open of the client (openChannel, :1643-1682:
|
|
14
|
+
* session, direct-tcpip and direct-streamlocal@openssh.com).
|
|
15
|
+
* - lib/utils.js:7-26: onChannelOpenFailure calls back with an Error whose
|
|
16
|
+
* message is `(SSH) Channel open failure: ${description}` and whose `reason`
|
|
17
|
+
* is the code. A CHANNEL_CLOSE in place of the answer (:28-34) gives the
|
|
18
|
+
* message `... server closed channel unexpectedly` and a `reason` of ''. The
|
|
19
|
+
* loss of the connection gives an Error with no `reason`.
|
|
20
|
+
*/
|
|
21
|
+
/** The reason code and the description of SSH_MSG_CHANNEL_OPEN_FAILURE, or undefined when the error of the open is not that message. */
|
|
22
|
+
export declare function channelOpenFailure(error: Error): {
|
|
23
|
+
readonly code: number;
|
|
24
|
+
readonly description: string;
|
|
25
|
+
} | undefined;
|
|
26
|
+
/** True when the server closed the channel in place of an answer to its open. */
|
|
27
|
+
export declare function closedBeforeOpen(error: Error): boolean;
|
|
28
|
+
//# sourceMappingURL=ssh2-channel-open-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-channel-open-failure.d.ts","sourceRoot":"","sources":["../src/ssh2-channel-open-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,wIAAwI;AACxI,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,GACX;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAQrE;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEtD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every use of the internals of ssh2 1.17.0 for a channel open that the
|
|
3
|
+
* server refused. ssh2 is pinned exactly; re-check each line below on a
|
|
4
|
+
* version bump.
|
|
5
|
+
*
|
|
6
|
+
* Why: @types/ssh2 types the error of a channel open as a plain Error, and
|
|
7
|
+
* ssh2 documents no field for the reason code of SSH_MSG_CHANNEL_OPEN_FAILURE
|
|
8
|
+
* (RFC 4254 §5.1). OpenChannelError gives that code.
|
|
9
|
+
*
|
|
10
|
+
* - lib/protocol/handlers.misc.js:855-881: SSH_MSG_CHANNEL_OPEN_FAILURE is
|
|
11
|
+
* parsed into the recipient, the reason code (uint32) and the description.
|
|
12
|
+
* - lib/client.js:564-571: the client hands `{ reason, description }` to
|
|
13
|
+
* onChannelOpenFailure, for each open of the client (openChannel, :1643-1682:
|
|
14
|
+
* session, direct-tcpip and direct-streamlocal@openssh.com).
|
|
15
|
+
* - lib/utils.js:7-26: onChannelOpenFailure calls back with an Error whose
|
|
16
|
+
* message is `(SSH) Channel open failure: ${description}` and whose `reason`
|
|
17
|
+
* is the code. A CHANNEL_CLOSE in place of the answer (:28-34) gives the
|
|
18
|
+
* message `... server closed channel unexpectedly` and a `reason` of ''. The
|
|
19
|
+
* loss of the connection gives an Error with no `reason`.
|
|
20
|
+
*/
|
|
21
|
+
/** The reason code and the description of SSH_MSG_CHANNEL_OPEN_FAILURE, or undefined when the error of the open is not that message. */
|
|
22
|
+
export function channelOpenFailure(error) {
|
|
23
|
+
if (!('reason' in error) || typeof error.reason !== 'number') {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
code: error.reason,
|
|
28
|
+
description: error.message.replace(/^\(SSH\) Channel open failure: /, ''),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** True when the server closed the channel in place of an answer to its open. */
|
|
32
|
+
export function closedBeforeOpen(error) {
|
|
33
|
+
return 'reason' in error && error.reason === '';
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ssh2-channel-open-failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-channel-open-failure.js","sourceRoot":"","sources":["../src/ssh2-channel-open-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,wIAAwI;AACxI,MAAM,UAAU,kBAAkB,CAChC,KAAY;IAEZ,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7D,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,MAAM;QAClB,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,iCAAiC,EAAE,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,OAAO,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every use of the internals of ssh2 1.17.0 for the keepalive request of the
|
|
3
|
+
* client. ssh2 is pinned exactly; re-check each line below on a version bump.
|
|
4
|
+
*
|
|
5
|
+
* Why: the keepalive runs on the clock of the config (root ADR 0004), with
|
|
6
|
+
* OpenSSH's ServerAliveInterval semantics (src/server-alive-check.ts), so the
|
|
7
|
+
* package leaves ssh2's keepalive off (no keepaliveInterval) and sends the
|
|
8
|
+
* request itself. ssh2 sends it only from its own keepalive timer.
|
|
9
|
+
*
|
|
10
|
+
* - lib/protocol/Protocol.js:87-95, :343-353: `_protocol.ping()` sends
|
|
11
|
+
* SSH_MSG_GLOBAL_REQUEST keepalive@openssh.com with want reply.
|
|
12
|
+
* - lib/client.js:501-508: REQUEST_SUCCESS and REQUEST_FAILURE call the first
|
|
13
|
+
* callback of `callbacks`, the queue of the global requests of the client in
|
|
14
|
+
* the order they went out. `callbacks` is `_callbacks` (:248) until the
|
|
15
|
+
* socket closes (:823), which calls each one left with an Error.
|
|
16
|
+
* - lib/client.js:716-734: sendKA pushes a callback onto `callbacks` just
|
|
17
|
+
* before `proto.ping()`, to keep that order.
|
|
18
|
+
*/
|
|
19
|
+
import type ssh2 from 'ssh2';
|
|
20
|
+
declare module 'ssh2' {
|
|
21
|
+
interface Client {
|
|
22
|
+
readonly _callbacks: (() => void)[];
|
|
23
|
+
readonly _protocol: ClientProtocol;
|
|
24
|
+
}
|
|
25
|
+
interface ClientProtocol {
|
|
26
|
+
ping(): void;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Sends keepalive@openssh.com with want reply. Its answer goes to no one, as OpenSSH's empty placeholder (clientloop.c:server_alive_check of 10.0p1): the arrival of any data counts. */
|
|
30
|
+
export declare function sendKeepaliveRequest(connection: ssh2.Client): void;
|
|
31
|
+
//# sourceMappingURL=ssh2-keepalive-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-keepalive-request.d.ts","sourceRoot":"","sources":["../src/ssh2-keepalive-request.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,MAAM;QACd,QAAQ,CAAC,UAAU,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACpC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;KACpC;IACD,UAAU,cAAc;QACtB,IAAI,IAAI,IAAI,CAAC;KACd;CACF;AAED,0LAA0L;AAC1L,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAGlE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Sends keepalive@openssh.com with want reply. Its answer goes to no one, as OpenSSH's empty placeholder (clientloop.c:server_alive_check of 10.0p1): the arrival of any data counts. */
|
|
2
|
+
export function sendKeepaliveRequest(connection) {
|
|
3
|
+
connection._callbacks.push(() => undefined);
|
|
4
|
+
connection._protocol.ping();
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ssh2-keepalive-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-keepalive-request.js","sourceRoot":"","sources":["../src/ssh2-keepalive-request.ts"],"names":[],"mappings":"AA8BA,0LAA0L;AAC1L,MAAM,UAAU,oBAAoB,CAAC,UAAuB;IAC1D,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAC5C,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Connection, ServerChannel, Session } from 'ssh2';
|
|
2
|
+
interface ChannelEnd {
|
|
3
|
+
readonly id: number;
|
|
4
|
+
readonly state: 'open' | 'eof' | 'closing' | 'closed';
|
|
5
|
+
}
|
|
6
|
+
interface ChannelInfo {
|
|
7
|
+
readonly outgoing: ChannelEnd;
|
|
8
|
+
}
|
|
9
|
+
interface Protocol {
|
|
10
|
+
channelSuccess(id: number): void;
|
|
11
|
+
channelFailure(id: number): void;
|
|
12
|
+
exitStatus(id: number, status: number): void;
|
|
13
|
+
readonly _packetRW: {
|
|
14
|
+
readonly write: {
|
|
15
|
+
readonly allocStart: number;
|
|
16
|
+
alloc(length: number): Buffer;
|
|
17
|
+
finalize(packet: Buffer): Buffer;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly _handlers: {
|
|
21
|
+
readonly CHANNEL_REQUEST?: (protocol: Protocol, recipient: number, type: string, wantReply: boolean, data: unknown) => void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare module 'ssh2' {
|
|
25
|
+
interface Session {
|
|
26
|
+
readonly _chanInfo: ChannelInfo;
|
|
27
|
+
_channel: ServerChannel | undefined;
|
|
28
|
+
}
|
|
29
|
+
interface Connection {
|
|
30
|
+
readonly _protocol: Protocol;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Makes ssh2 give each pty-req of this connection with its modes, also one with a mode that ssh2 does not name. */
|
|
34
|
+
export declare function parseTerminalModes(connection: Connection): void;
|
|
35
|
+
/**
|
|
36
|
+
* Sends the replies of the requests of one session channel in the order of the
|
|
37
|
+
* requests (RFC 4254 §5.4), whatever order the caller answers them in.
|
|
38
|
+
*/
|
|
39
|
+
export declare class SessionReplies {
|
|
40
|
+
#private;
|
|
41
|
+
constructor(connection: Connection, session: Session);
|
|
42
|
+
/** A slot for one request; its first call sends the reply. A request with no reply wanted gets a slot that sends nothing. */
|
|
43
|
+
reserve(wantReply: boolean): (success: boolean) => void;
|
|
44
|
+
}
|
|
45
|
+
/** The channel of an exec or shell request, opened before the reply so that no data is lost. undefined when the session already has one. */
|
|
46
|
+
export declare function openCommandChannel(connection: Connection, session: Session): ServerChannel | undefined;
|
|
47
|
+
/** After a refused exec or shell, the session can take another. */
|
|
48
|
+
export declare function dropCommandChannel(session: Session): void;
|
|
49
|
+
/** exit-status or exit-signal, also after EOF (RFC 4254 §6.10 allows it), then SSH_MSG_CHANNEL_CLOSE. */
|
|
50
|
+
export declare function exitCommandChannel(connection: Connection, session: Session, channel: ServerChannel, status: number | {
|
|
51
|
+
readonly signal: string;
|
|
52
|
+
readonly coreDumped: boolean;
|
|
53
|
+
readonly errorMessage: string;
|
|
54
|
+
}): void;
|
|
55
|
+
/**
|
|
56
|
+
* The end of the channel sends only EOF, as a half-close (RFC 4254 §5.3);
|
|
57
|
+
* CLOSE follows once the peer sent EOF too. ssh2 sends both at the end.
|
|
58
|
+
*/
|
|
59
|
+
export declare function halfClosing(channel: ServerChannel): ServerChannel;
|
|
60
|
+
/** ssh2 starts a keepalive timer at 'ready'; the server has no timer (ADR 0011). */
|
|
61
|
+
export declare function removeKeepalive(connection: Connection): void;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=ssh2-server-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh2-server-channel.d.ts","sourceRoot":"","sources":["../src/ssh2-server-channel.ts"],"names":[],"mappings":"AA0CA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/D,UAAU,UAAU;IAClB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;CACvD;AAED,UAAU,WAAW;IACnB,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC/B;AAED,UAAU,QAAQ;IAChB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IA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