feat(hosts): manage servers and encrypted SSH credentials in UI (#7)

This commit is contained in:
Florian Schmidt
2026-11-16 10:19:52 +01:00
parent 4fe7e4e376
commit 4d9a632625
22 changed files with 1779 additions and 81 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import { Server, utils, type Connection } from "ssh2";
import type { HostInfo } from "@shellbook/core";
import type { ServerConfig } from "../src/config";
import { fingerprint } from "../src/ssh";
export async function createSshFixture(config: ServerConfig, cleanup: (() => Promise<unknown>)[], authenticate = true) {
export async function createSshFixture(config: ServerConfig, cleanup: (() => Promise<unknown>)[], authenticate: boolean | ((ctx: import("ssh2").AuthContext) => void) = true) {
const key = generateKeyPairSync("rsa", { modulusLength: 2048 }).privateKey.export({ type: "pkcs1", format: "pem" }).toString();
const parsed = utils.parseKey(key);
if (parsed instanceof Error) throw parsed;
@@ -15,7 +15,7 @@ export async function createSshFixture(config: ServerConfig, cleanup: (() => Pro
clients.add(client);
client.on("error", () => {});
client.on("close", () => clients.delete(client));
client.on("authentication", ctx => authenticate ? ctx.accept() : ctx.reject());
client.on("authentication", ctx => typeof authenticate === "function" ? authenticate(ctx) : authenticate ? ctx.accept() : ctx.reject());
client.on("ready", () => client.on("session", accept => {
const session = accept();
session.on("exec", (acceptExec, _reject, info) => {