Skip to content

tools: phone-ssh: layer explicit endpoints onto shared connections - #57

Merged
derekross merged 2 commits into
derekross:mainfrom
wirelessjoe:fix/phone-ssh-options
Oct 30, 2026
Merged

derekross merged 2 commits into
derekross:mainfrom
wirelessjoe:fix/phone-ssh-options

Conversation

@wirelessjoe

@wirelessjoe wirelessjoe commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Add explicit OMAMOBILE_SSH_HOST, OMAMOBILE_SSH_KEY and OMAMOBILE_SSH_KNOWN_HOSTS options to tools/phone-ssh, preserving main's shared connections, --fresh and --stop. Explicit identities and known-hosts policies get separate connection masters; known-host filenames are quoted for OpenSSH's parser.

Address the review by shortening the custom policy hash to 12 hex characters. Keep %C so changes to the effective SSH host or port still select a separate master. Under /run/user/1000, OpenSSH's 17-byte temporary suffix previously made the path 111 bytes, exceeding Linux's 107-byte limit. It is now 99 bytes, or 105 with the longest decimal UID runtime path. Default connections retain main's control path.

Document the variables in the usage comment and CONTRIBUTING beside OMAMOBILE_SSH_SHARE. Rebased onto main a6034a5. This PR can merge independently of the flame work.

Validation

  • tests/phone-ssh: the socket-length regression reproduced 111 bytes before the fix and passes at 99/105 bytes afterward. A real OpenSSH -G fixture verifies alias host/port changes select separate masters without opening a connection. Sharing, fresh/stop, policy isolation and path tests pass.
  • tests/all: passed in the Linux test container. Optional Docker provisioning, AOSP image, GPG local-build and root-image cases skipped because fixtures or tools were unavailable.
  • shellcheck tools/phone-ssh tests/phone-ssh, tools/pr-check origin/main and git diff --check: passed.
  • GitHub CI at bd104a3: policy, tests/all and every package suite passed. No package files changed.
  • Host-side tooling only; no phone connection, reboot, flash or on-phone change in this revision.

@derekross

Copy link
Copy Markdown
Owner

Thanks, this is a careful change. I compared it with main's version for every combination of --fresh, --stop and OMAMOBILE_SSH_SHARE, and with none of the new variables set the ssh arguments are the same (only the option order moved), and the control path is unchanged, so existing shared connections carry over. The quoting of the known-hosts path also holds up against real OpenSSH, spaces and quotes included, and a wrong host key is refused.

One problem before I merge: with the explicit options and OMAMOBILE_SSH_SHARE=1, the shared connection fails on a normal Linux desktop. OpenSSH first binds the master at the control path plus a 17-character temporary suffix, and with XDG_RUNTIME_DIR=/run/user/1000 that comes to 111 bytes, over the 107-byte limit for a Unix socket:

unix_listener: path "/run/user/1000/omamobile-ssh-<24 hex>-<40 hex>.<16 chars>" too long for Unix domain socket

ssh exits 255 and nothing runs. It works with XDG_RUNTIME_DIR=/tmp, which may be what your check used, and the fake-ssh test can't see it. Since the context hash already covers the target, could you drop the -%C from the custom path (or shorten the hash to 12 characters), and add a test that the custom path plus 17 fits in 107 bytes with XDG_RUNTIME_DIR=/run/user/1000?

Smaller: please add the three variables to the usage comment at the top, and a sentence in CONTRIBUTING next to OMAMOBILE_SSH_SHARE. If you retitle it tools: phone-ssh: … it'll match the earlier commit on this file, but that's optional.

derekross added a commit that referenced this pull request Oct 27, 2026
…#93)

CONTRIBUTING's shared-driver rule asked for identical objects, which a
per-SoC flag tested inside a shared function can't give (kernel #57); a
per-function diff that shows only the new SoC's path changing is the
evidence there, and per-SoC data reaches fallback-compatible boards too.

husky's UFS plan said Tensor G4's host data has no suspend hook; kernel
#83 adds one, and husky binds that data through its fallback compatible.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@W4HO-ham W4HO-ham mentioned this pull request Oct 28, 2026
10 of 14 tasks
@derekross

Copy link
Copy Markdown
Owner

Checking in on this one, since it's small and stands on its own: the only thing left from my 10-26 comment is the control path being too long for a Unix socket once connection sharing is on. Dropping %C from the path (or shortening the hash), plus a test that builds the longest path we'd use, would do it, and then it can merge independently of the flame PRs.

For the flame set (#55, #56, #58, #59): no rush, but main has moved a lot since 10-27, so each will need a rebase. Version numbers have also moved: omamobile-shell 0.2.33 to 0.2.39 are taken by open PRs, so #55 would need 0.2.40 (or whatever is free when it lands), and omamobile-firstboot is at 0.1.3 in #97. #58 still needs the CONTRIBUTING §3.1 entry for flame (LUN, the four sectors, the attribute bit and CRCs), the GPT rollback, the slot flags before and after, and the way back. If you'd rather I close #17 now that it's split into these, say so.

wirelessjoe and others added 2 commits October 29, 2026 16:50
Retain sharing, --fresh and --stop while supporting a scoped USB
endpoint, identity and strict known-hosts file. Isolate shared masters
by their explicit identity and host-key context. Fake-SSH fixtures cover
default compatibility, argv, sharing and fresh connections; no phone is
contacted.

Co-Authored-By: Codex <noreply@openai.com>
A 24-hex policy context plus OpenSSH %C makes the temporary master
socket exceed Linux sun_path under /run/user/1000. Shorten the policy
context to 12 hex characters and retain %C so effective HostName and
Port changes in ssh_config still select different masters. Default
connections keep their upstream control path.

The length regression reproduced 111 bytes before this fix and now
passes at 99 and 105 bytes, including the temporary 17-byte suffix.
A real OpenSSH -G fixture also verifies host/port alias isolation
without opening a connection. Document the three explicit options in
the usage comment and beside sharing in CONTRIBUTING.

Co-Authored-By: Codex <noreply@openai.com>
@wirelessjoe
wirelessjoe force-pushed the fix/phone-ssh-options branch from fcdbabe to bd104a3 Compare October 29, 2026 20:58
@wirelessjoe wirelessjoe changed the title phone-ssh: layer explicit endpoints onto shared connections tools: phone-ssh: layer explicit endpoints onto shared connections Oct 29, 2026
@derekross
derekross merged commit 2d1ed7f into derekross:main Oct 30, 2026
2 checks passed
@derekross

Copy link
Copy Markdown
Owner

Thanks, this is exactly the fix. The 12-character policy hash keeps %C, so a change of host or port in someone's ssh_config still gets its own master, and the path now fits. I checked it myself: with XDG_RUNTIME_DIR=/run/user/1000 and a custom key, the master's temporary path is 99 bytes, and 105 with the longest UID, under the 107-byte limit. tests/phone-ssh passes here, with its real ssh -G check, and so does CI on bd104a3.

Since every Pixel 7 Pro session goes through this script, I also compared main and your head with none of the new variables set. I tried plain, --fresh and --stop, each with and without OMAMOBILE_SSH_SHARE=1, and ran both argument lists through OpenSSH 10.6's ssh -G. The effective configuration is byte-identical in all six cases, and the default control path is unchanged, so existing shared connections carry over. A known-hosts path with spaces and quotes still parses to the right file.

The usage comment, the CONTRIBUTING line and the title are all in as well. Merging now, thank you.

robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…erekross#57)

OMAMOBILE_SSH_HOST (user@host), OMAMOBILE_SSH_KEY (an identity file, with
IdentitiesOnly) and OMAMOBILE_SSH_KNOWN_HOSTS (strict host-key checking
against that file) let a contributor reach a phone that isn't at
root@172.16.42.1 with the default trust-on-every-boot options.

With any of them set, a shared connection's control path adds a 12-character
hash of the target, the resolved identity and known-hosts paths and their
contents, so a different key, a rotated key or a changed host key never
reuses another master; %C stays for the effective host and port. The path
plus OpenSSH's 17-byte temporary suffix fits the 107-byte Unix socket limit
(99 bytes under /run/user/1000, 105 with the longest UID), and
tests/phone-ssh checks it. Without sharing, explicit options force a new
connection even when the user's ssh_config shares globally.

With none of the variables set, the ssh options are unchanged (only their
order moved; `ssh -G` output identical for plain, --fresh and --stop, with
and without OMAMOBILE_SSH_SHARE), and so is the default control path.
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.

2 participants