Repository navigation
Conversation
|
@greptileai review |
|
|
Thanks for the thorough review! We've addressed all 6 findings in commit
@greptileai review |
|
Addressed the remaining 2 findings in commit
@greptileai review |
- Prevent unrelated includes from falsely blocking installation - Preserve global settings by placing include before host blocks and adding Match all - Parse target destination to match bare hostnames and record User directive - Support custom port in managed host entry - Add file locking to serialize concurrent syncs - Handle symlinked SSH config files cleanly
…ctions - Use Match host <host> [user <user>] [exec "test %p = <port>"] when user or port are specified so that distinct live sessions targeting the same host retain separate ControlPath sockets without collisions or overwrites. - Order managed config stanzas by specificity so that specific Match blocks take precedence over generic Host fallback entries in OpenSSH evaluation. - Support tab-separated Host\t and Match\t sections when determining the managed Include insertion point in user SSH configs. - Add unit tests verifying distinct multi-target coexistence on the same host and tab-separated section detection.
2e31de4 to
0ae87b3
Compare
…egacy entry normalization - Allow custom-port Match stanzas to match when commands are invoked without explicit -p (where %p defaults to 22), ensuring agents reuse authenticated sockets - Restrict bare alias and default-port stanzas to %p = 22 to prevent unrelated custom-port commands from hijacking bare alias sockets - Re-render all managed entries on write to automatically migrate and normalize legacy Host stanzas into scoped Match blocks - Add unit and OpenSSH resolution tests verifying connection reuse, isolation, and legacy migration
|
Addressed the 3 findings in commit
@greptileai review |
…h two-stage resolution
|
Addressed the 2 findings in commit 7b894a5:
@greptileai review |
| out.push_str(&format!( | ||
| "Match final host {host} user {u} exec \"test %p = {p}\"\n ControlMaster auto\n ControlPath {}\n", | ||
| socket_path.display() | ||
| )); |
There was a problem hiding this comment.
Bare alias socket takes precedence
When a bare alias and a custom-port target share a hostname, the bare alias’s Host block sets ControlPath in OpenSSH’s first config pass. The custom-port target sets its path only in Match final, which cannot replace that earlier value. Even ssh -p <custom-port> user@host can therefore reuse the bare alias’s socket instead of the requested target’s authenticated connection.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/jobs/ssh.rs
Line: 151-154
Comment:
**Bare alias socket takes precedence**
When a bare alias and a custom-port target share a hostname, the bare alias’s `Host` block sets `ControlPath` in OpenSSH’s first config pass. The custom-port target sets its path only in `Match final`, which cannot replace that earlier value. Even `ssh -p <custom-port> user@host` can therefore reuse the bare alias’s socket instead of the requested target’s authenticated connection.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Addressed finding in commit 3309323: User-only match ignores port:
@greptileai review |
|
Addressed finding in commit 2b66510: Configured port blocks socket reuse:
@greptileai review |
|
Addressed finding in commit 95b09aa: Old port reuses socket:
@greptileai review |
|
thanks for this, and for pushing on agent connection reuse in #432. the feature landed in main through a different route, and #862 keeps it working on the new run engine: plain |
Closes #432
Problem
When
orxestablishes connections to remote compute hosts (especially multi-hop bastion/jump hosts or OTP/password authentications), it creates an authenticated SSH multiplex master socket (/tmp/orx-ssh-<uid>-<hash>/<target_hash>).However, when coding agents in chat sessions or shell commands execute
ssh <host> ..., OpenSSH reads~/.ssh/config. Without the matchingControlPathin~/.ssh/config:sshcommand fails with authentication errors./proc, searching environment files, testingssh -vvv, and trying to recover.orxalready has an active, authenticated tunnel to that host.Solution
OpenSSH natively supports
Includedirectives (OpenSSH 7.3+). This PR adds a managed SSH config include:~/.config/openresearch/ssh_config(viacrate::config::config_dir().join("ssh_config")).orx,orxupdates its entry in~/.config/openresearch/ssh_config:user@when matchingHostentries, souser@hosttargets emitHost <host>with an explicitUser <user>directive.-p <port>or:port) are recorded on theHostblock so commands intended for default/other ports do not inadvertently attach to a master socket bound to a different port.Match allto prevent trailing host scope from leaking into subsequent directives on older OpenSSH versions (< 8.4).managed_ssh_config.lock).Include ~/.config/openresearch/ssh_configis in~/.ssh/config.Includedirective is inserted immediately before the firstHostorMatchsection (or appended if none exist), preserving any global options specified at the top of~/.ssh/config./etc/ssh/ssh_configby validating canonical and tilde-expanded paths.ControlPersistfor maximum server compatibility, relying directly onorx's active background master process.Testing
upsert_managed_host_entry_creates_new_file_and_updates: Verifies new file creation, entry updates, and preserving sibling host blocks.upsert_managed_host_entry_handles_user_and_port: Verifiesuser@hostsplitting, port extraction, andMatch allscoping.ensure_ssh_config_include_preserves_global_settings_before_hosts: Verifies that global directives precedingHostblocks remain untouched and global.ensure_ssh_config_include_does_not_false_positive_on_other_includes: Verifies that unrelatedInclude /etc/ssh/ssh_configlines do not block installation.ensure_ssh_config_include_supports_symlink: Verifies symlinked~/.ssh/configfiles are resolved and written atomically without breaking symlinks.ensure_ssh_config_include_in_inserts_and_is_idempotent: Verifies idempotency and missing file creation.cargo fmt --all --check,cargo clippy --all-targets -- -D warnings, and full test suite (cargo test --locked).