Commit 5463fdc
committed
feat(ssh): native SSH support via an allowlisted ssh_exec tool
Lets the agent run commands on remote machines without giving up the
security boundary. The agent targets hosts by NAME (e.g. \"staging\"),
never by free-form user@host strings — even with prompt injection,
the model can only pick from the user's enrolled allowlist.
Components:
- src/ssh/config.ts — reads + validates ~/.codebase/ssh.json (user-wide)
and <cwd>/.codebase/ssh.json (project, project wins on name conflict).
Rejects host fields that smell like smuggled user@host:port syntax;
enforces name pattern, port range, identityFile shape.
- src/ssh/store.ts — atomic add/list/rm of user-wide hosts; writes the
file at mode 0600.
- src/ssh/cli.ts — `codebase ssh add | list | rm | test | keygen`.
keygen defaults to Ed25519 (faster, smaller, modern); --rsa generates
RSA-4096 for compliance / legacy infra. Files chmod 0600 on the
private key, 0644 on the public key. Passphrase-less by design
(the agent must run non-interactively), documented in the keygen
output with the `ssh-keygen -p` recipe if the user wants to add
one later.
- src/tools/ssh-exec.ts — wraps `ssh` with safe defaults:
BatchMode=yes (no password prompts ever), ConnectTimeout=10s,
StrictHostKeyChecking=accept-new (TOFU on first connection, strict
after), ServerAliveInterval=30s, IdentitiesOnly=yes when --key is
set. Applies the local shell-validator to the remote command too —
rm -rf / over SSH blocks the same way.
Tests: 20 new (config + store + tool integration). 774 total passing.
Docs: SSH section in CLAUDE.md covering enrollment, security model,
config schema.1 parent 6c2c52c commit 5463fdc
12 files changed
Lines changed: 1219 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
274 | 356 | | |
275 | 357 | | |
276 | 358 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
| 61 | + | |
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
| |||
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
| |||
0 commit comments