@ornncompute/cli 1.0.161 → 1.0.162
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 +3 -2
- package/package.json +1 -1
- package/src/admin-ssh.mjs +31 -0
package/README.md
CHANGED
|
@@ -474,8 +474,9 @@ Staff can use `ornn admin ssh <node-id>` for certificate access on nodes that tr
|
|
|
474
474
|
the environment's SSH CA. It requires an interactive staff login, creates a temporary
|
|
475
475
|
local key, obtains a 15-minute certificate through the gateway and launches
|
|
476
476
|
OpenSSH with normal host-key verification. Nodes configured for the staff SSH
|
|
477
|
-
relay connect through Orchestrator automatically.
|
|
478
|
-
|
|
477
|
+
relay connect through Orchestrator automatically. For a supplier jump host,
|
|
478
|
+
OpenSSH uses your existing gateway credentials for the first hop and the
|
|
479
|
+
certificate for the node hop. Temporary files are removed when the command exits.
|
|
479
480
|
|
|
480
481
|
Gateway-bound connections resolve their gateway before producing SSH commands.
|
|
481
482
|
Forwarded endpoints remain a single SSH destination. Supplier-provided jump hosts
|
package/package.json
CHANGED
package/src/admin-ssh.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as orchestrator from "../vendor/api-client/orchestrator.js";
|
|
2
|
+
import { sshArguments } from "../vendor/capabilities/cli.js";
|
|
2
3
|
import { spawn } from "node:child_process";
|
|
3
4
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { isIP } from "node:net";
|
|
4
6
|
import { constants, tmpdir } from "node:os";
|
|
5
7
|
import { join } from "node:path";
|
|
6
8
|
import { ADMIN_MUTATION_SAFETY } from "./admin-mutations.mjs";
|
|
@@ -21,6 +23,33 @@ function run(program, args, signal) {
|
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
async function supplierJumpArguments(fetch, node, host, port, signal) {
|
|
27
|
+
if (node.ssh_relay_configured === true || !node.ssh_gateway_id) return [];
|
|
28
|
+
const gateway = await orchestrator.getSupplierGateway(fetch, node.ssh_gateway_id, signal);
|
|
29
|
+
if (gateway?.id !== node.ssh_gateway_id) {
|
|
30
|
+
throw new Error("The node's SSH gateway is unavailable.");
|
|
31
|
+
}
|
|
32
|
+
if (gateway.ssh_access_mode === "forwarded") return [];
|
|
33
|
+
const address = gateway.public_ip ?? gateway.hostname;
|
|
34
|
+
if (
|
|
35
|
+
gateway.ssh_access_mode !== "jump" ||
|
|
36
|
+
typeof address !== "string" ||
|
|
37
|
+
!(
|
|
38
|
+
/^[A-Za-z0-9][A-Za-z0-9.-]*$/.test(address) ||
|
|
39
|
+
(/^[A-Fa-f0-9:.]+$/.test(address) && isIP(address) === 6)
|
|
40
|
+
) ||
|
|
41
|
+
typeof gateway.ssh_username !== "string" ||
|
|
42
|
+
!/^(?!-)[A-Za-z0-9_.-]{1,32}$/.test(gateway.ssh_username) ||
|
|
43
|
+
!Number.isInteger(gateway.ssh_port) ||
|
|
44
|
+
gateway.ssh_port < 1 ||
|
|
45
|
+
gateway.ssh_port > 65535
|
|
46
|
+
) {
|
|
47
|
+
throw new Error("The node's SSH jump gateway has invalid connection details.");
|
|
48
|
+
}
|
|
49
|
+
const args = sshArguments({ host, port, username: "admin", gateway });
|
|
50
|
+
return [...args.slice(0, 2), "-o", "ControlPath=none"];
|
|
51
|
+
}
|
|
52
|
+
|
|
24
53
|
export async function openAdminSsh(
|
|
25
54
|
{ input, fetch, execute, runtime },
|
|
26
55
|
{ runProcess = run, openRelay = openSshRelay } = {}
|
|
@@ -51,6 +80,7 @@ export async function openAdminSsh(
|
|
|
51
80
|
controller.abort();
|
|
52
81
|
});
|
|
53
82
|
try {
|
|
83
|
+
const jumpOptions = await supplierJumpArguments(fetch, node, host, port, signal);
|
|
54
84
|
directory = await mkdtemp(join(tmpdir(), "ornn-ssh-"));
|
|
55
85
|
const key = join(directory, "identity");
|
|
56
86
|
const generated = await runProcess(
|
|
@@ -98,6 +128,7 @@ export async function openAdminSsh(
|
|
|
98
128
|
"-p",
|
|
99
129
|
String(relay?.port ?? port),
|
|
100
130
|
...relayOptions,
|
|
131
|
+
...jumpOptions,
|
|
101
132
|
"-l",
|
|
102
133
|
"admin",
|
|
103
134
|
host,
|