@crvouga/homelab 0.23.5 → 0.23.6

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 CHANGED
@@ -198,6 +198,35 @@ before the revision's own run script starts there; a manager whose installed
198
198
  homelab is from before that question refuses such a revision rather than
199
199
  passing it.
200
200
 
201
+ ## Unattended SSH
202
+
203
+ For fleets with `nativeSsh: true`, `check --workers` also measures SSH from
204
+ that declared manager: its authenticated identity, the effective alias/account
205
+ and port, the worker's native SSH preference, durable policy acceptance in both
206
+ directions, and a fresh local forwarding channel to the declared T3 endpoint.
207
+ A cached or expired browser approval never proves unattended access: temporary
208
+ policy rules are excluded from the durable grant check. Policy inspection that
209
+ is denied or unavailable fails verification; daemon health alone cannot pass it.
210
+ The manager must be allowed to read its Tailscale netmap, and the worker's
211
+ existing noninteractive sudo grant must permit the read-only Tailscale probes.
212
+
213
+ These checks run after native SSH adoption on every converge, including the
214
+ existing manager schedule. `notify` runs `check --workers`, so persistent SSH
215
+ failures and recovery reach the fleet's configured notification targets. SSH
216
+ connection attempts and keepalives are bounded; later scheduled runs retry
217
+ transient failures. Converge reconciles the owned daemon and SSH preference
218
+ using Ansible. An unreachable machine needs its consumer-owned console or a
219
+ verified alternate route; homelab cannot repair a disconnected SSH route over
220
+ that same route. Missing or revoked identities stay unhealthy until enrollment
221
+ is restored. Host keys are never learned automatically.
222
+
223
+ The consumer's infrastructure owner reconciles scoped noninteractive SSH
224
+ acceptance and forwarding policy. Homelab reads the effective policy and
225
+ verifies it again after reconciliation; it never changes that cloud policy or
226
+ asks for a browser approval during a normal run. Alias drift is reported for
227
+ the consumer to fix. The forwarding probe verifies a `direct-tcpip` channel to
228
+ the T3 loopback service; a VS Code server installation remains a separate check.
229
+
201
230
  ## Your project's own tools
202
231
 
203
232
  On a fleet machine the global mise configuration (`~/.config/mise/config.toml`
package/docs/runbooks.md CHANGED
@@ -14,7 +14,7 @@ It reads a code by where it stands, never by the word it ends with. The CLI
14
14
  proxy documents the codes of its own commands in
15
15
  [its README](../cliproxy/README.md); the ones converge reports are here.
16
16
 
17
- There are 498 codes; 105 need a person.
17
+ There are 506 codes; 111 need a person.
18
18
 
19
19
  ## Bootstrap of a new or returning worker
20
20
 
@@ -770,3 +770,19 @@ To authorize every enrolled environment's agents to work with full access on eve
770
770
  - `DISK_GC_OPERATIONS_FAILED`: one or more collector operations failed, were refused by the reserve, or could not safely inventory open temporary packs. A successful scheduler exit does not establish successful collection.
771
771
  - `MANAGER_LEGACY_AGENTS_REMAIN`: an exact historical LaunchAgent label remains installed or loaded. Convergence removes it only after its replacement is loaded, preserving service availability.
772
772
  - `MANAGER_RESOURCE_GUARD_UNSUPPORTED`: macOS has no supported fleet CPU/memory/I/O admission, pressure guard or low-disk writer guard. Scheduled collection and background job priority do not provide those guarantees.
773
+
774
+ ## Continuous unattended SSH verification
775
+
776
+ - **Meaning:** Native SSH health is measured from the declared manager. A running daemon, reachable port or recently approved browser check is not durable access. Temporary policy grants are excluded before evaluating the effective policy, including the return route to the manager.
777
+ - **Confirm:** Run `homelab check --workers --json` on the manager. Check the separate client identity, effective alias, service preference, policy and forwarding checks. Raw netmaps, credentials, delegation URLs and subprocess output are never included in the report.
778
+ - **Fix:** `homelab converge` reconciles owned local services and native SSH preferences, then verifies connectivity again. The existing converge schedule retries transient failures; `homelab notify` checks these same failures and sends alerts through configured targets. A consumer infrastructure owner reconciles scoped noninteractive policy, then repeats verification. No browser approval is a permanent remedy.
779
+ - **Escalate:** With no reachable SSH route, use the consumer-owned console or an independently verified alternate route. A disconnected route cannot repair itself over SSH. Never disable host-key checking, broaden cloud grants implicitly, expose public SSH, reset an existing identity or copy auth responses into an issue.
780
+
781
+ - `SSH_CLIENT_IDENTITY_UNVERIFIED`: the probe did not originate from the declared authenticated manager, its identity expired, or its daemon/status could not be verified. Restore the manager's existing enrollment and service; a worker checking itself is insufficient. **Needs a person.**
782
+ - `SSH_CONFIGURATION_MISMATCH`: effective SSH hostname, user, native port or proxy route differs from the declaration. Reconcile the consumer-owned alias; no personal SSH configuration is rewritten. **Needs a person.**
783
+ - `SSH_SERVICE_UNVERIFIED`: the destination's native SSH preference is disabled or its read-only inspection failed. Run converge to reconcile the owned preference/daemon. If the route is lost, use the consumer-owned console.
784
+ - `SSH_POLICY_UNVERIFIED`: no supported effective netmap policy could be read. Restore read-only inspection privileges through the existing local privilege owner. A successful login cannot substitute for policy evidence. **Needs a person.**
785
+ - `SSH_POLICY_DENIED`: no permanent accepting rule matches the declared source/account, or a preceding matching rule rejects it. The consumer infrastructure owner must reconcile scoped access. **Needs a person.**
786
+ - `SSH_POLICY_ACCOUNT_MISMATCH`: the effective policy maps the requested SSH account to a different local account. Reconcile the scoped account mapping with its infrastructure owner. **Needs a person.**
787
+ - `SSH_POLICY_FORWARDING_DENIED`: a durable grant exists but does not allow the editor's local forwarding channel. The consumer infrastructure owner reconciles its forwarding permission. **Needs a person.**
788
+ - `SSH_FORWARDING_UNVERIFIED`: the bounded direct-tcpip probe did not receive a response from the declared T3 loopback endpoint. Converge the owned endpoint and SSH configuration, resolve any separately reported trust, network, credential or policy failure, then repeat verification. A shell session alone does not pass forwarding.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crvouga/homelab",
3
- "version": "0.23.5",
3
+ "version": "0.23.6",
4
4
  "description": "Keeps a set of development machines in sync: one manager and many workers",
5
5
  "license": "MIT",
6
6
  "repository": "github:crvouga/homelab",
@@ -73,5 +73,5 @@
73
73
  "engines": {
74
74
  "node": ">=22"
75
75
  },
76
- "gitHead": "90b62f0ee5385cd7eab10801c5496641116d6f06"
76
+ "gitHead": "74086ff155477e1d9d265f106d7bc5415bca05ac"
77
77
  }
@@ -1479,6 +1479,22 @@
1479
1479
  },
1480
1480
  "requirement": true
1481
1481
  },
1482
+ {
1483
+ "id": "ssh:client",
1484
+ "meaning": "SSH connectivity was measured from the declared authenticated manager.",
1485
+ "severity": "required",
1486
+ "repair": {
1487
+ "manual": "SSH trust (host keys, keys in the agent, the alias) is set up by a person once per machine; homelab never accepts a host key for you."
1488
+ }
1489
+ },
1490
+ {
1491
+ "id": "ssh:configuration",
1492
+ "meaning": "The effective SSH alias reaches the declared native SSH destination, user and port without a proxy.",
1493
+ "severity": "required",
1494
+ "repair": {
1495
+ "manual": "SSH trust (host keys, keys in the agent, the alias) is set up by a person once per machine; homelab never accepts a host key for you."
1496
+ }
1497
+ },
1482
1498
  {
1483
1499
  "id": "ssh:disconnected",
1484
1500
  "meaning": "The SSH session was not lost while an operation ran.",
@@ -1495,6 +1511,14 @@
1495
1511
  "manual": "SSH trust (host keys, keys in the agent, the alias) is set up by a person once per machine; homelab never accepts a host key for you."
1496
1512
  }
1497
1513
  },
1514
+ {
1515
+ "id": "ssh:forwarding",
1516
+ "meaning": "A fresh strict SSH direct-tcpip channel reached the declared editor endpoint.",
1517
+ "severity": "required",
1518
+ "repair": {
1519
+ "manual": "SSH trust (host keys, keys in the agent, the alias) is set up by a person once per machine; homelab never accepts a host key for you."
1520
+ }
1521
+ },
1498
1522
  {
1499
1523
  "id": "ssh:fresh-session",
1500
1524
  "meaning": "A fresh, host-key-verified SSH session succeeded.",
@@ -1528,6 +1552,22 @@
1528
1552
  "manual": "SSH trust (host keys, keys in the agent, the alias) is set up by a person once per machine; homelab never accepts a host key for you."
1529
1553
  }
1530
1554
  },
1555
+ {
1556
+ "id": "ssh:policy",
1557
+ "meaning": "The effective destination SSH policy durably accepts the declared source and account with local forwarding.",
1558
+ "severity": "required",
1559
+ "repair": {
1560
+ "manual": "The consumer infrastructure owner reconciles scoped noninteractive tailnet SSH authorization; homelab verifies it and never broadens access."
1561
+ }
1562
+ },
1563
+ {
1564
+ "id": "ssh:policy-return",
1565
+ "meaning": "The effective manager SSH policy durably accepts the declared worker and account with local forwarding.",
1566
+ "severity": "required",
1567
+ "repair": {
1568
+ "manual": "The consumer infrastructure owner reconciles scoped noninteractive tailnet SSH authorization; homelab verifies it and never broadens access."
1569
+ }
1570
+ },
1531
1571
  {
1532
1572
  "id": "ssh:probe",
1533
1573
  "meaning": "A remote probe over SSH succeeded.",
@@ -1552,6 +1592,14 @@
1552
1592
  "manual": "SSH trust (host keys, keys in the agent, the alias) is set up by a person once per machine; homelab never accepts a host key for you."
1553
1593
  }
1554
1594
  },
1595
+ {
1596
+ "id": "ssh:service",
1597
+ "meaning": "The destination native SSH preference is enabled.",
1598
+ "severity": "required",
1599
+ "repair": {
1600
+ "manual": "Run converge: it reconciles the declared native SSH preference and daemon. An unreachable machine needs its consumer-owned console or a verified alternate route."
1601
+ }
1602
+ },
1555
1603
  {
1556
1604
  "id": "ssh:session",
1557
1605
  "meaning": "A noninteractive SSH session and probe succeeded.",
@@ -141,6 +141,21 @@ export const CHECK_OWNERS: CheckOwner[] = [
141
141
  'Re-converge the worker with converge: it applies the Ubuntu baseline.',
142
142
  },
143
143
  { pattern: 'platform:*', manual: HARDWARE },
144
+ {
145
+ pattern: 'ssh:service',
146
+ manual:
147
+ 'Run converge: it reconciles the declared native SSH preference and daemon. An unreachable machine needs its consumer-owned console or a verified alternate route.',
148
+ },
149
+ {
150
+ pattern: 'ssh:policy',
151
+ manual:
152
+ 'The consumer infrastructure owner reconciles scoped noninteractive tailnet SSH authorization; homelab verifies it and never broadens access.',
153
+ },
154
+ {
155
+ pattern: 'ssh:policy-return',
156
+ manual:
157
+ 'The consumer infrastructure owner reconciles scoped noninteractive tailnet SSH authorization; homelab verifies it and never broadens access.',
158
+ },
144
159
  {
145
160
  pattern: 'ssh:*',
146
161
  manual:
@@ -384,6 +384,17 @@ export const CHECK_MEANINGS: Record<string, string> = {
384
384
  'source:bootstrap':
385
385
  'The approved bootstrap source is available on the manager.',
386
386
  'ssh:agent': 'The SSH agent exposes at least one identity.',
387
+ 'ssh:configuration':
388
+ 'The effective SSH alias reaches the declared native SSH destination, user and port without a proxy.',
389
+ 'ssh:client':
390
+ 'SSH connectivity was measured from the declared authenticated manager.',
391
+ 'ssh:service': 'The destination native SSH preference is enabled.',
392
+ 'ssh:policy':
393
+ 'The effective destination SSH policy durably accepts the declared source and account with local forwarding.',
394
+ 'ssh:policy-return':
395
+ 'The effective manager SSH policy durably accepts the declared worker and account with local forwarding.',
396
+ 'ssh:forwarding':
397
+ 'A fresh strict SSH direct-tcpip channel reached the declared editor endpoint.',
387
398
  'ssh:auth': 'SSH key or agent authentication succeeded.',
388
399
  'ssh:disconnected': 'The SSH session was not lost while an operation ran.',
389
400
  'ssh:dns': 'The SSH host name resolved.',
@@ -1,3 +1,4 @@
1
+ import { sshConnectivity } from '../ssh-health';
1
2
  import { managerCustomizations } from '../state/t3-customizations';
2
3
  import { managerClientSettings } from '../state/t3-client-settings';
3
4
  import { clientFailure } from '../t3/client-settings';
@@ -416,6 +417,7 @@ function deployWithMonitoring(
416
417
  };
417
418
  return deployWorker(node, revision, {
418
419
  definition: canonical,
420
+ verifyConnectivity: (target) => sshConnectivity(target, run),
419
421
  playbook: packagePlaybook(run),
420
422
  converge,
421
423
  control: () =>
@@ -28,6 +28,7 @@ import {
28
28
  */
29
29
  export interface WorkerDeployment {
30
30
  definition: FleetDefinition;
31
+ verifyConnectivity?: (node: FleetNode) => Promise<Check[]>;
31
32
  /** Applies a playbook of the package from the manager. */
32
33
  playbook: PackagePlaybook;
33
34
  /** One converge of the worker; `tailnetKey` is handed to its bootstrap. */
@@ -108,6 +109,7 @@ export async function deployWorker(
108
109
  )
109
110
  ) {
110
111
  result.checks.push(await nativeSsh(target, deployment));
112
+ result.checks.push(...(await connectivity(target, deployment)));
111
113
  }
112
114
  result.checks.unshift(...before, ...maintenance);
113
115
  return result;
@@ -305,3 +307,12 @@ async function nativeSsh(
305
307
  remedy,
306
308
  };
307
309
  }
310
+
311
+ function connectivity(
312
+ node: FleetNode,
313
+ deployment: WorkerDeployment
314
+ ): Promise<Check[]> {
315
+ return deployment.verifyConnectivity
316
+ ? deployment.verifyConnectivity(node)
317
+ : Promise.resolve([]);
318
+ }
@@ -0,0 +1,260 @@
1
+ import { fleet } from './fleet-config';
2
+ import { record } from './config';
3
+ import { sshArgs, sshFailure } from './ssh';
4
+ import { sshPolicyCheck, type SshPrincipal } from './ssh-policy';
5
+ import type { Check, FleetNode, Runner } from './types';
6
+ import type { MachineDefinition } from './definition';
7
+
8
+ type Network = NonNullable<MachineDefinition['network']>;
9
+
10
+ function document(text: string): Record<string, unknown> | null {
11
+ try {
12
+ const value: unknown = JSON.parse(text);
13
+ return record(value) ? value : null;
14
+ } catch {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ function principal(
20
+ status: Record<string, unknown>,
21
+ node: Record<string, unknown>
22
+ ): SshPrincipal | null {
23
+ const id = node['ID'];
24
+ const ips = node['TailscaleIPs'];
25
+ if (
26
+ typeof id !== 'string' ||
27
+ !Array.isArray(ips) ||
28
+ !ips.length ||
29
+ !ips.every((ip) => typeof ip === 'string')
30
+ )
31
+ return null;
32
+ const users = status['User'];
33
+ const user = record(users) ? users[String(node['UserID'])] : null;
34
+ const login = record(user) ? user['LoginName'] : null;
35
+ return { id, ips, ...(typeof login === 'string' ? { login } : {}) };
36
+ }
37
+
38
+ const normalized = (name: unknown): string =>
39
+ String(name).replace(/\.$/, '').toLowerCase();
40
+
41
+ function authenticated(
42
+ status: Record<string, unknown> | null
43
+ ): status is Record<string, unknown> {
44
+ if (
45
+ !status ||
46
+ status['BackendState'] !== 'Running' ||
47
+ !record(status['Self'])
48
+ )
49
+ return false;
50
+ if (Array.isArray(status['Health']) && status['Health'].length) return false;
51
+ const expires = status['Self']['KeyExpiry'];
52
+ // Tagged identities can omit expiry or use the Go zero time.
53
+ if (typeof expires === 'string' && !expires.startsWith('0001-')) {
54
+ if (!(Date.parse(expires) > Date.now())) return false;
55
+ }
56
+ return (
57
+ normalized(status['Self']['DNSName']) ===
58
+ normalized(fleet.manager.network.tailscaleName)
59
+ );
60
+ }
61
+
62
+ async function clientContext(network: Network, run: Runner) {
63
+ const local = await run(['tailscale', 'status', '--json'], {
64
+ timeoutMs: 15_000,
65
+ });
66
+ const status = local.ok ? document(local.stdout) : null;
67
+ if (!authenticated(status)) return null;
68
+ const self = status['Self'];
69
+ const peers = status['Peer'];
70
+ if (!record(self) || !record(peers)) return null;
71
+ const peer = Object.values(peers).find(
72
+ (value) =>
73
+ record(value) &&
74
+ normalized(value['DNSName']) === normalized(network.tailscaleName)
75
+ );
76
+ if (!record(peer)) return null;
77
+ const source = principal(status, self);
78
+ const reverse = principal(status, peer);
79
+ return source && reverse ? { source, reverse } : null;
80
+ }
81
+
82
+ function correctConfiguration(
83
+ text: string,
84
+ network: Network,
85
+ ips: string[]
86
+ ): boolean {
87
+ const configuration = new Map(
88
+ text.split('\n').map((line) => {
89
+ const [key, ...value] = line.trim().split(/\s+/);
90
+ return [key, value.join(' ')];
91
+ })
92
+ );
93
+ const host = normalized(configuration.get('hostname'));
94
+ return (
95
+ (host === normalized(network.tailscaleName) || ips.includes(host)) &&
96
+ configuration.get('user') === network.user &&
97
+ configuration.get('port') === '22' &&
98
+ ['none', undefined].includes(configuration.get('proxyjump')) &&
99
+ ['none', undefined].includes(configuration.get('proxycommand'))
100
+ );
101
+ }
102
+
103
+ async function configurationCheck(
104
+ remote: string[],
105
+ network: Network,
106
+ ips: string[],
107
+ run: Runner
108
+ ): Promise<Check> {
109
+ const result = await run([...remote.slice(0, -1), '-G', remote.at(-1)!], {
110
+ timeoutMs: 10_000,
111
+ });
112
+ const valid = result.ok && correctConfiguration(result.stdout, network, ips);
113
+ return {
114
+ id: 'ssh:configuration',
115
+ status: valid ? 'pass' : 'fail',
116
+ summary: valid
117
+ ? 'Effective SSH destination, account and native port match the declaration without a jump host.'
118
+ : 'SSH_CONFIGURATION_MISMATCH',
119
+ remedy: {
120
+ action:
121
+ 'Reconcile the consumer-owned SSH alias with the declared tailnet destination, account and native SSH port 22. Remove unexpected proxy routing. Homelab does not rewrite personal SSH configuration or relax host trust.',
122
+ },
123
+ };
124
+ }
125
+
126
+ async function serviceCheck(remote: string[], run: Runner): Promise<Check> {
127
+ const prefs = await run([...remote, 'sudo -n tailscale debug prefs'], {
128
+ timeoutMs: 15_000,
129
+ });
130
+ const settings = prefs.ok ? document(prefs.stdout) : null;
131
+ const enabled = settings?.['RunSSH'] === true;
132
+ return {
133
+ id: 'ssh:service',
134
+ status: enabled ? 'pass' : 'fail',
135
+ summary: enabled
136
+ ? 'Native SSH is enabled on the destination daemon.'
137
+ : 'SSH_SERVICE_UNVERIFIED',
138
+ remedy: {
139
+ action:
140
+ 'Run converge to reconcile the declared native SSH preference and enabled daemon. If SSH is unavailable, use the consumer-owned console or verified alternate transport; no remote repair is possible over a disconnected route.',
141
+ },
142
+ };
143
+ }
144
+
145
+ async function policyChecks(
146
+ remote: string[],
147
+ network: Network,
148
+ context: { source: SshPrincipal; reverse: SshPrincipal },
149
+ run: Runner
150
+ ): Promise<Check[]> {
151
+ const map = await run([...remote, 'sudo -n tailscale debug netmap'], {
152
+ timeoutMs: 15_000,
153
+ });
154
+ const forward = sshPolicyCheck(
155
+ map.ok ? document(map.stdout) : null,
156
+ context.source,
157
+ network.user
158
+ );
159
+ const localMap = await run(['tailscale', 'debug', 'netmap'], {
160
+ timeoutMs: 15_000,
161
+ });
162
+ const reverse = sshPolicyCheck(
163
+ localMap.ok ? document(localMap.stdout) : null,
164
+ context.reverse,
165
+ fleet.manager.network.user
166
+ );
167
+ return [forward, { ...reverse, id: 'ssh:policy-return' }];
168
+ }
169
+
170
+ const HTTP_STATUS = /^HTTP\/1\.[01] \d{3}[^\r\n]*\r?\n/;
171
+
172
+ async function forwardingChecks(
173
+ remote: string[],
174
+ network: Network,
175
+ run: Runner
176
+ ): Promise<Check[]> {
177
+ // Exercise the editor's direct-tcpip channel against the declared loopback
178
+ // endpoint. No listening port, persistent tunnel or server is made.
179
+ const result = await run(
180
+ [
181
+ ...remote.slice(0, -1),
182
+ '-W',
183
+ `127.0.0.1:${network.t3Port}`,
184
+ remote.at(-1)!,
185
+ ],
186
+ {
187
+ input: 'HEAD / HTTP/1.0\r\nHost: localhost\r\n\r\n',
188
+ timeoutMs: 15_000,
189
+ stopWhen: (output) => HTTP_STATUS.test(output),
190
+ }
191
+ );
192
+ const forwarded =
193
+ (result.ok || result.reason === 'stopped') &&
194
+ HTTP_STATUS.test(result.stdout);
195
+ const checks: Check[] = [
196
+ {
197
+ id: 'ssh:forwarding',
198
+ status: forwarded ? 'pass' : 'fail',
199
+ summary: forwarded
200
+ ? 'A fresh strict SSH direct-tcpip channel reached the declared editor endpoint.'
201
+ : 'SSH_FORWARDING_UNVERIFIED',
202
+ ...(!forwarded
203
+ ? {
204
+ remedy: {
205
+ action:
206
+ 'Verify the declared T3 loopback service and scoped local forwarding permission. Reconcile owned services with converge and cloud authorization with the consumer infrastructure owner, then rerun check --workers. No public port or relaxed host trust is needed.',
207
+ },
208
+ }
209
+ : {}),
210
+ },
211
+ ];
212
+ if (!forwarded && !result.ok) checks.push(sshFailure(result));
213
+ return checks;
214
+ }
215
+
216
+ /** Manager-originated evidence. Only declared native SSH fleets opt in.
217
+ * No returned check contains daemon output, identities or authorization URLs.
218
+ * Runs after adoption, on scheduled converge and on health/notify.
219
+ */
220
+ export async function sshConnectivity(
221
+ node: FleetNode,
222
+ run: Runner
223
+ ): Promise<Check[]> {
224
+ if (!fleet.nativeSsh) return [];
225
+ const network = fleet.workers.find((entry) => entry.id === node.id)?.network;
226
+ const context = network ? await clientContext(network, run) : null;
227
+ const id = 'ssh:client';
228
+ if (!context || !network)
229
+ return [
230
+ {
231
+ id,
232
+ status: 'fail',
233
+ summary: 'SSH_CLIENT_IDENTITY_UNVERIFIED',
234
+ remedy: {
235
+ action:
236
+ 'Run this check on the declared manager with a running, authenticated Tailscale daemon. Restore its identity through the existing network repair or converge. A worker checking itself cannot verify manager connectivity.',
237
+ },
238
+ },
239
+ ];
240
+ const remote = sshArgs(node);
241
+ const checks: Check[] = [
242
+ {
243
+ id,
244
+ status: 'pass',
245
+ summary: 'SSH probes originate on the declared authenticated manager.',
246
+ },
247
+ ];
248
+ const configuration = await configurationCheck(
249
+ remote,
250
+ network,
251
+ context.reverse.ips,
252
+ run
253
+ );
254
+ checks.push(configuration);
255
+ if (configuration.status !== 'pass') return checks;
256
+ checks.push(await serviceCheck(remote, run));
257
+ checks.push(...(await policyChecks(remote, network, context, run)));
258
+ checks.push(...(await forwardingChecks(remote, network, run)));
259
+ return checks;
260
+ }
@@ -0,0 +1,89 @@
1
+ import { record } from './config';
2
+ import type { Check } from './types';
3
+
4
+ export interface SshPrincipal {
5
+ id: string;
6
+ ips: string[];
7
+ login?: string;
8
+ }
9
+
10
+ const POLICY_REMEDY = {
11
+ action:
12
+ 'Reconcile the consumer-owned tailnet policy with its infrastructure owner: grant scoped noninteractive SSH accept access from the declared source to the declared destination account, including local port forwarding for the editor. Temporary check approvals do not satisfy this dependency. If inspection is unverified, restore read-only netmap access through the existing local privilege owner; no policy success is inferred from a denied probe. Homelab never edits cloud access policy. Rerun converge and check --workers after reconciliation.',
13
+ };
14
+
15
+ /** Evaluate the destination daemon’s effective policy, not a cached login.
16
+ * Expiring rules are intentionally excluded: they can hide a check rule.
17
+ * Unknown or incomplete documents never establish unattended access.
18
+ */
19
+ export function sshPolicyCheck(
20
+ map: unknown,
21
+ source: SshPrincipal,
22
+ user: string
23
+ ): Check {
24
+ const id = 'ssh:policy';
25
+ const policy = record(map) ? map['SSHPolicy'] : null;
26
+ const rules = record(policy) ? policy['rules'] : null;
27
+ const summary = policyResult(rules, source, user);
28
+ return summary === 'pass'
29
+ ? {
30
+ id,
31
+ status: 'pass',
32
+ summary:
33
+ 'Durable scoped SSH acceptance and local forwarding verified independently of cached approvals.',
34
+ }
35
+ : { id, status: 'fail', summary, remedy: POLICY_REMEDY };
36
+ }
37
+
38
+ function policyResult(
39
+ rules: unknown,
40
+ source: SshPrincipal,
41
+ user: string
42
+ ): string {
43
+ if (!Array.isArray(rules) || !source.id || !source.ips.length || !user)
44
+ return 'SSH_POLICY_UNVERIFIED';
45
+ for (const rule of rules) {
46
+ const result = ruleResult(rule, source, user);
47
+ if (result !== 'ignore') return result;
48
+ }
49
+ return 'SSH_POLICY_DENIED';
50
+ }
51
+
52
+ function ruleResult(rule: unknown, source: SshPrincipal, user: string): string {
53
+ if (!record(rule)) return 'SSH_POLICY_UNVERIFIED';
54
+ if (rule['ruleExpires']) return 'ignore';
55
+ const principals = rule['principals'];
56
+ if (!Array.isArray(principals)) return 'SSH_POLICY_UNVERIFIED';
57
+ if (!principals.some((value) => principalMatches(value, source)))
58
+ return 'ignore';
59
+ const users = rule['sshUsers'];
60
+ const action = rule['action'];
61
+ if (record(action) && action['reject'] === true && !users)
62
+ return 'SSH_POLICY_DENIED';
63
+ return userResult(users, action, user);
64
+ }
65
+
66
+ function userResult(users: unknown, action: unknown, user: string): string {
67
+ if (!record(users)) return 'ignore';
68
+ const mapped = users[user] ?? users['*'];
69
+ if (typeof mapped !== 'string' || !mapped) return 'ignore';
70
+ if (mapped !== '=' && mapped !== user) return 'SSH_POLICY_ACCOUNT_MISMATCH';
71
+ if (!record(action) || action['reject'] === true) return 'SSH_POLICY_DENIED';
72
+ if (action['holdAndDelegate'])
73
+ return 'TAILSCALE_INTERACTIVE_AUTHORIZATION_REQUIRED';
74
+ if (action['accept'] !== true) return 'SSH_POLICY_DENIED';
75
+ if (action['allowLocalPortForwarding'] !== true)
76
+ return 'SSH_POLICY_FORWARDING_DENIED';
77
+ return 'pass';
78
+ }
79
+
80
+ function principalMatches(value: unknown, source: SshPrincipal): boolean {
81
+ if (!record(value)) return false;
82
+ return (
83
+ value['any'] === true ||
84
+ value['node'] === source.id ||
85
+ (typeof value['nodeIP'] === 'string' &&
86
+ source.ips.includes(value['nodeIP'])) ||
87
+ (source.login !== undefined && value['userLogin'] === source.login)
88
+ );
89
+ }
@@ -1,3 +1,4 @@
1
+ import { sshConnectivity } from './ssh-health';
1
2
  import { compareFingerprints } from './fingerprint';
2
3
  import { probe } from './probe';
3
4
  import { inspectRemote } from './transport';
@@ -70,6 +71,7 @@ export async function tailnetHealth(
70
71
  },
71
72
  run
72
73
  );
74
+ checks.push(...(await sshConnectivity(node, run)));
73
75
  return combine(peer, checks, report, manager);
74
76
  });
75
77
  const absent = nodes.filter(