Dippy icon indicating copy to clipboard operation
Dippy copied to clipboard

Feature request: trust SSH host aliases from ~/.ssh/config to suppress ask on every ssh ...

Open philipstancil opened this issue 6 months ago β€’ 1 comments

Dippy currently returns ask on every ssh … invocation, which is the right default β€” the local AST has no view of what runs on the other end of the pipe, so the engine can't make a soundness judgment. But for hosts the operator has already curated into ~/.ssh/config, the prompt is friction without value: the trust decision was made when the host alias was added.

I'd like a way to declare a set of SSH host aliases as pre-trusted, so a single ssh ... call routes to allow without consulting the operator each time, while preserving Dippy's existing behavior for everything else (chained commands, command substitution, unknown hosts, inline interpreters, etc.).

Concrete examples

These four invocations all come up routinely in my workflow, all currently prompt:

ssh foo-server 'free -h && uptime' /usr/bin/ssh foo-server 'cd /home/x && git log -2' ssh foo-laptop 'bash -lc "jq -r .field file.json"' ssh client-server 'ls public_html'

'foo-server', 'foo-laptop', and 'client-server' are all (fictitious for this purpose) explicit Host aliases in my ~/.ssh/config β€” they're not wildcards, not external lookups, just literal alias entries I curated for fleet/client work.

Proposed shape

A few possible designs, in rough preference order:

  1. Auto-trust literal Host aliases from ~/.ssh/config. Default off; opt-in via flag or config. Dippy already has a clear policy boundary; this just promotes "explicit alias in operator-owned config" to the trusted-target set. Wildcards (Host *) and negations (Host !foo) would be skipped β€” only literal aliases count. Include directives would be followed.
  2. Explicit config option (e.g., ~/.config/dippy/trust.toml or env var) listing trusted SSH hosts: [ssh] trust_hosts = ["foo-server", "foo-laptop", "client-server"]
  3. CLI flag for one-off use: dippy --trust-ssh-host=foo-server,foo-laptop.

A or B as the durable mechanism, C as a debugging knob.

Soundness considerations

The trust should only apply to a single ssh ... invocation with no top-level shell operators outside quotes. If any of &&, ||, ;, |, &, <, >, $(...), or backticks appears at the top level, the command should fall back to the normal ask decision β€” otherwise ssh foo-server 'foo'; rm -rf /tmp/x would slip through. The remote payload (inside the quoted string) stays out of scope; it's already out of Dippy's reach by virtue of being remote.

The user@host form should resolve to host for the trust lookup. Absolute-path /usr/bin/ssh and any /.../ssh should be treated the same as bare ssh.

Why I'm asking

I run a small fleet (one VPS, two Macs, many SPanel client accounts), all aliased in /.ssh/config. Routine ops work β€” checking memory, tailing logs, running quick gitqueries on the VPS β€” produces a constant stream of prompts that I always approve. I built a narrow local wrapper around the Dippy hook that promotes single trusted-host SSH calls toallow, but that's an integration detail that ideally lives upstream β€” the trust shape is general enough that any Dippy operator with a curated ~/.ssh/config would benefit.

Happy to send a PR if you'd accept the design. Open to a different shape if you'd prefer.

Environment

Dippy 0.2.7 (Homebrew tap, macOS arm64) Claude Code, PreToolUse:Bash hook integration Thanks for building this β€” the AST-based gating approach is the right model and the parser quality (Parable's test count) shows in how many ambiguous cases it gets right.

philipstancil avatar May 08 '26 18:05 philipstancil

Thanks for this β€” it's a thoughtful writeup, and the soundness framing ("the local AST has no view of what runs on the other end") is exactly right.

Having looked at both this and #138 (an SSH handler that delegates the remote command for analysis), I'm leaning toward #138's shape as the better fit for Dippy's philosophy. Dippy's value is being discerning β€” analyzing what a command does and approving only what it can see is safe β€” rather than granting blanket trust. Host-trust is closer to "allow anything to this host," which trades that discernment away (a destructive command to a trusted host would auto-approve just like a read-only one).

The nice part is that #138 likely covers most of your friction already, with no config at all: I checked, and your read-only examples β€” free -h && uptime, cd /home/x && git log -2, ls public_html, and the jq one β€” all classify as allow under that delegation, because those commands are inherently read-only. It's the mutating ones (a git pull or systemctl restart on your own box) that would still prompt β€” and that's the genuinely host-trust-shaped slice your proposal addresses that #138 doesn't.

Your point that Dippy can't truly analyze the remote side is fair, but under its threat model (catching mistakes, not adversaries) "a read-only command is read-only regardless of host" holds up well enough to lean on.

One hesitation specific to the ~/.ssh/config auto-trust variant: it couples Dippy to an external format it doesn't own (Include directives, wildcards, negations, and the "I aliased a host" β‰  "I want unattended command exec there" leap). If a host-trust layer ever does land, an explicit opt-in list would be the safer shape than parsing ssh config.

Really appreciate you engaging at this level of detail β€” and for #144, which we fixed.

ldayton avatar Jun 08 '26 14:06 ldayton