ssh-config: make the ssh <name>.vm shortcut opt-in
Before this change, every daemon.Open() wrote a Host *.vm stanza into
~/.ssh/config in a marker-fenced block. That's a real footgun for users
who manage their SSH config declaratively (chezmoi, dotfiles, NixOS):
banger was mutating host state outside its own directory on every
daemon start, easy to miss and hard to audit.
New contract: the daemon only ever writes its own ssh_config file at
~/.config/banger/ssh_config. ~/.ssh/config is untouched unless the user
opts in. `banger vm ssh <name>` still works out of the box — the
shortcut only matters for plain `ssh sandbox.vm` from any terminal.
The opt-in surface is `banger ssh-config`:
banger ssh-config # prints path + include-line +
# install/uninstall hints
banger ssh-config --install # adds `Include <bangerConfig>` to
# ~/.ssh/config inside a marker-fenced
# block; idempotent; migrates any
# legacy inline Host *.vm block from
# pre-opt-in builds
banger ssh-config --uninstall # removes the new Include block AND
# any legacy inline block
Doctor gains a gentle warn-level note when banger's ssh_config exists
but the user hasn't wired it in — not a fail, since the shortcut is
convenience and `banger vm ssh` covers the essential case.
Tests cover: daemon writes banger file and does NOT touch ~/.ssh/config,
Install adds the block, Install is idempotent, Install migrates the
legacy inline block cleanly (removing it, preserving unrelated
entries, adding the new Include block), Uninstall removes both marker
variants, Uninstall is a no-op when ~/.ssh/config is absent, and
UserSSHIncludeInstalled detects both marker shapes.
README reframes the feature as optional convenience.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
99d0811097
commit
108f7a0600
7 changed files with 509 additions and 82 deletions
24
README.md
24
README.md
|
|
@ -101,12 +101,28 @@ leaves the VM alive for `banger vm logs` inspection.
|
|||
## Hostnames: reaching `<vm>.vm`
|
||||
|
||||
banger's daemon runs a DNS server for the `.vm` zone. With host-side
|
||||
DNS routing you can `ssh root@sandbox.vm` or `curl
|
||||
http://sandbox.vm:3000` from anywhere on the host — no copy-pasting
|
||||
guest IPs. On systemd-resolved hosts this is auto-wired; everywhere
|
||||
else there's a short recipe. See
|
||||
DNS routing you can `curl http://sandbox.vm:3000` from anywhere on
|
||||
the host — no copy-pasting guest IPs. On systemd-resolved hosts this
|
||||
is auto-wired; everywhere else there's a short recipe. See
|
||||
[`docs/dns-routing.md`](docs/dns-routing.md).
|
||||
|
||||
### Optional: `ssh <name>.vm` shortcut
|
||||
|
||||
`banger vm ssh <name>` works out of the box. If you'd also like plain
|
||||
`ssh sandbox.vm` from any terminal (using banger's key + known_hosts),
|
||||
opt in:
|
||||
|
||||
```bash
|
||||
banger ssh-config --install # adds `Include ~/.config/banger/ssh_config`
|
||||
# to ~/.ssh/config in a marker-fenced block
|
||||
banger ssh-config --uninstall # reverse it
|
||||
banger ssh-config # show the include line to paste manually
|
||||
```
|
||||
|
||||
banger never touches `~/.ssh/config` on its own — the daemon keeps its
|
||||
file fresh at `~/.config/banger/ssh_config`; whether and how it's
|
||||
pulled into your SSH config is up to you.
|
||||
|
||||
## Image catalog
|
||||
|
||||
`banger image pull <name>` fetches a pre-built bundle from the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue