Skip to content

Enable SSH host key verification when gateway provides fingerprint#4

Merged
persimmon16 merged 1 commit intofeat/apple-containerfrom
security/ssh-host-key
Apr 1, 2026
Merged

Enable SSH host key verification when gateway provides fingerprint#4
persimmon16 merged 1 commit intofeat/apple-containerfrom
security/ssh-host-key

Conversation

@persimmon16
Copy link
Copy Markdown
Owner

Summary

  • F10: SSH connections now use StrictHostKeyChecking=yes with a temporary known_hosts file when the gateway's host_key_fingerprint field is populated
  • Behavior is unchanged when the field is empty (current default) — no-verify mode remains until F11 populates the fingerprint

Affects: CLI (openshell-cli), TUI (openshell-tui)

Test plan

  • cargo build -p openshell-cli -p openshell-tui succeeds
  • SSH connections work unchanged (empty fingerprint → current behavior)
  • When a fingerprint is injected, SSH verifies the host key

When the gateway provides a host_key_fingerprint in CreateSshSessionResponse,
write a temporary known_hosts file and enable StrictHostKeyChecking=yes.
When the fingerprint is empty (current default), behavior is unchanged.

This is scaffolding for F10/F11 — once the gateway populates the fingerprint
field, MITM protection activates automatically in both CLI and TUI.
@persimmon16 persimmon16 merged commit b63cda9 into feat/apple-container Apr 1, 2026
5 of 11 checks passed
persimmon16 added a commit that referenced this pull request Apr 1, 2026
… leak

Three bugs from the initial SSH host-key PR (#4):

1. known_hosts wrote [sandbox]:2222 but SSH connects to "sandbox" at
   default port 22 — entry never matched, defeating StrictHostKeyChecking.
   Fixed to use bare "sandbox" hostname.

2. tempfile crate was only in [dev-dependencies] for openshell-cli,
   breaking release builds. Moved to [dependencies].

3. TempDir::into_path() disabled automatic cleanup, leaking temp
   directories. Changed to return the TempDir guard so callers keep it
   alive until SSH exits, then cleanup runs on drop.

Also fixes borrow-checker error in grpc.rs auth check (PR #5) where
.ok_or_else() borrowed request while into_inner() tried to move it.
persimmon16 added a commit that referenced this pull request Apr 1, 2026
* Fix SSH host key verification: hostname format, tempfile dep, TempDir leak

Three bugs from the initial SSH host-key PR (#4):

1. known_hosts wrote [sandbox]:2222 but SSH connects to "sandbox" at
   default port 22 — entry never matched, defeating StrictHostKeyChecking.
   Fixed to use bare "sandbox" hostname.

2. tempfile crate was only in [dev-dependencies] for openshell-cli,
   breaking release builds. Moved to [dependencies].

3. TempDir::into_path() disabled automatic cleanup, leaking temp
   directories. Changed to return the TempDir guard so callers keep it
   alive until SSH exits, then cleanup runs on drop.

Also fixes borrow-checker error in grpc.rs auth check (PR #5) where
.ok_or_else() borrowed request while into_inner() tried to move it.

* Install Apple Container in macOS e2e workflow

The macos-15 runner doesn't ship with Apple Container pre-installed.
Download the signed .pkg installer from the GitHub release and install
it before running container system info.
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