IF Commons GitHub

surfaces/ssh-inbound/mod

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-reach-and-targets FR-008

The inbound side of ssh (commons headless 0005-reach-and-targets FR-008): not a model of its own, but what is generated from the governance reach policy so that the machine that is reached is configured to let in exactly what the policy allows: the lines of authorized_keys that force a key to one command (restrict, command="<program> mcp", or the run-json entry <program> run --ssh, with --read-only for a key that may only read), and the Match block of sshd_config that takes away what a forced command does not need (a terminal, forwarding, an agent). It writes text and reads no file.

A public key is not a secret, but a private one MUST NOT reach this: a text that is not one public key line is refused, naming no part of it.

import { authorizedKeysLine } from "./mod.ts";
authorizedKeysLine({ program: "ops", mode: "mcp", key: { name: "probe", publicKey: "ssh-ed25519 AAAAC3Nza probe", role: "full" } });
// { kind: "ok", value: 'restrict,command="ops mcp" ssh-ed25519 AAAAC3Nza probe' }

Source: commons/headless/src/surfaces/ssh-inbound/mod.ts

5 of 11 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

KeyRoletypeno test imports it
type KeyRole = "read-only" | "full";

What a key may do: only run what reads, or run what the policy lets its channel run.

InboundKeytypeno test imports it
type InboundKey = { readonly name: string; readonly publicKey: string; readonly role: KeyRole; readonly from?: readonly string[] };

A key to let in: its name (for a person), the public key line, its role, and the addresses it may come from.

InboundModetypeno test imports it
type InboundMode = "mcp" | "run" | "program";

The forced commands: a tool server over ssh, one run of a verb with a JSON report, or a program that is not ours to run and that reads only (a probe script), forced as it is.

forcedCommandfunction
function forcedCommand(program: string, mode: InboundMode, role: KeyRole): string

The command a mode forces, for a role: <program> mcp or <program> run --ssh, with --read-only for a key that may only read; for the mode program, the program alone, which is what it is that reads only.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

authorizedKeysLinefunction
function authorizedKeysLine(i: { readonly program: string; readonly mode: InboundMode; readonly key: InboundKey; }): Result<string, string>

One line of authorized_keys, or why it cannot be made: a program name that could break out of the quotes, an address pattern that is not one, or a text that is not one public key.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

modesForfunction
function modesFor(actions: readonly Reached[], role: KeyRole): readonly InboundMode[]

The modes the policy of the actions lets a key into: a tool server where any action is reached through mcp, a run of a verb where any is reached through ssh; for a read-only key, only by actions that read.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

InboundPlantypeno test imports it
type InboundPlan = { readonly lines: readonly string[]; readonly problems: readonly string[] };

What is generated: the lines of authorized_keys (a key for each mode its policy allows), and what could not be made.

inboundPlanfunction
function inboundPlan(program: string, actions: readonly Reached[], keys: readonly InboundKey[]): InboundPlan

The authorized_keys lines for the keys, from the reach policy of the actions: no line for a mode no action is reached through, none at all where nothing is.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

MatchInputtypeno test imports it
type MatchInput = { readonly user: string; readonly addresses?: readonly string[] };

What a Match block is for: the account the keys log in as, and optionally the addresses it is limited to.

matchBlockfunction
function matchBlock(i: MatchInput): Result<string, string>

The Match block of sshd_config for the account: only public keys, no terminal, no forwarding of any kind, no agent, no personal rc file. A user name that is not one is refused.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

isInboundChannelfunctionno test imports it
function isInboundChannel(c: string): c is Channel

Whether a channel is one the inbound generator is for.

Titles, headings, exports, tables, columns and requirements. Esc closes.