Skip to content

Accept unknown ssh host keys on first connect - #119

Merged
dhh merged 2 commits into
mainfrom
ssh-accept-new-host-keys
Nov 5, 2026
Merged

dhh merged 2 commits into
mainfrom
ssh-accept-new-host-keys

Conversation

@dhh

@dhh dhh commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

gliff spawns ssh with no terminal attached, so for a host that isn't in known_hosts yet the "Are you sure you want to continue connecting?" prompt can't be answered and the connection fails. Until now the workaround was to ssh <host> in a terminal once first.

This passes -o StrictHostKeyChecking=accept-new to ssh:

  • New host: its key is saved to known_hosts and the connection goes ahead, the same as typing "yes".
  • Known host whose key changed: ssh still refuses to connect.
  • Your ssh config wins: gliff runs ssh -G for the host first and only adds accept-new when the effective StrictHostKeyChecking is still the default ask, so a configured yes (or anything else) is left alone.

scripts/check.sh passes. Not yet tried against a real host that's missing from known_hosts.

🤖 Generated with Claude Code

gliff spawns ssh without a terminal, so the host-key prompt for a host
not yet in known_hosts can't be answered and the connection fails until
the user has ssh'd in manually once. Pass StrictHostKeyChecking=accept-new:
new keys are recorded as if "yes" was typed, changed keys still fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[High impact] The PR changes host-key trust for Gliff's SSH connections.

The PR still needs to preserve explicitly configured SSH trust settings before merging.

Findings

  1. P1 Security Strict SSH settings are ignored ▶

Summary

The PR accepts unknown SSH host keys on first connection.

  • Gliff connects to new SSH hosts without an interactive host-key prompt.

Reviews (2) · Last reviewed commit: "Respect StrictHostKeyChecking set in ssh..." · Reviewed by Greptile

Comment thread crates/gliff-transport/src/ssh.rs Outdated
Comment on lines +66 to +67
.arg("-o")
.arg("StrictHostKeyChecking=accept-new")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Strict SSH settings are ignored

If a user sets StrictHostKeyChecking=yes in their SSH config, this command-line option overrides it and silently accepts unknown host keys. An attacker intercepting the first connection can then supply a key that the client accepts and saves.

The promised override through ssh_args is unavailable in the app: ssh_endpoint leaves it empty, and the CLI has no SSH-options flag. Preserve explicit SSH trust settings or provide a working user override.

How this was verified: Every app-created SshTarget leaves ssh_args empty, while the command-line StrictHostKeyChecking=accept-new takes precedence over SSH config.

A command-line -o overrides ssh config, so accept-new silently weakened
a user's StrictHostKeyChecking=yes. Ask ssh -G for the effective value
and only add accept-new when it is still the default "ask".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh merged commit f74bf61 into main Nov 5, 2026
5 checks passed
@dhh
dhh deleted the ssh-accept-new-host-keys branch November 5, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant