The best way to control Claude Code, Codex and more from any computer or phone
fix(ssh): skip directories in config includes (#25187)
Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com>
maria committed
Oct 29, 2026 at 17:44 UTC
ebc34dae6058a0b4ce05c3dc34c8fbf7cbe6e46e
2 files changed
+34
packages/ssh/src/config.test.ts
+33
@@ -56,6 +56,39 @@ describe("ssh config", () => {
56
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
57
);
58
59
+ it.effect("skips directory Include matches without losing file aliases or known hosts", () =>
60
+ Effect.gen(function* () {
61
+ const fs = yield* FileSystem.FileSystem;
62
+ const path = yield* Path.Path;
63
+ const homeDir = yield* makeTempHomeDir();
64
+ const sshDir = path.join(homeDir, ".ssh");
65
+ yield* fs.makeDirectory(path.join(sshDir, "config.d", "ignored"), { recursive: true });
66
+ yield* fs.makeDirectory(path.join(sshDir, "explicit-directory"));
67
+ yield* fs.writeFileString(
68
+ path.join(sshDir, "config"),
69
+ "Include config.d/*\nInclude explicit-directory\nHost real\n HostName real.example.com\n",
70
+ );
71
+ yield* fs.writeFileString(
72
+ path.join(sshDir, "config.d", "team.conf"),
73
+ "Host team\n HostName team.example.com\n",
74
+ );
75
+ yield* fs.writeFileString(
76
+ path.join(sshDir, "known_hosts"),
77
+ "known.example.com ssh-ed25519 AAAA\n",
78
+ );
79
+
80
+ const hosts = yield* discoverSshHosts({ homeDir });
81
+ assert.deepEqual(
82
+ hosts.map((host) => [host.alias, host.hostname, host.source]),
83
+ [
84
+ ["known.example.com", "known.example.com", "known-hosts"],
85
+ ["real", "real.example.com", "ssh-config"],
86
+ ["team", "team.example.com", "ssh-config"],
87
+ ],
88
+ );
89
+ }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
90
+ );
91
+
92
it.effect("discovers ssh config hosts across included files", () =>
93
Effect.gen(function* () {
94
const fs = yield* FileSystem.FileSystem;
packages/ssh/src/config.ts
+1
@@ -177,6 +177,7 @@ const collectSshConfigAliasesFromFile = Effect.fnUntraced(function* (
177
return;
178
}
179
if (!(yield* fs.exists(resolvedPath))) return;
180
+ if ((yield* fs.stat(resolvedPath)).type === "Directory") return;
181
visited.add(resolvedPath);
182
183
const directory = path.dirname(resolvedPath);