Skip to content

feat(ios): add a PC over SSH from the iPhone, as the Android app does - #4450

Merged
devswha merged 10 commits into
release/relay-0510from
feat/ios-phone-ssh
Nov 21, 2026
Merged

devswha merged 10 commits into
release/relay-0510from
feat/ios-phone-ssh

Conversation

@devswha

@devswha devswha commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What

The iPhone app adds a PC over SSH, the twin of the Android app's phone SSH (#3862): the same screens, steps,
words, failure kinds, shell commands and Manage actions, and app/web/connect.js drives it through the same
OvisSsh plugin methods. Nothing in server/ or shared/ changes.

  • app/ios/OvisSshCore (new local Swift package, over apple/swift-nio-ssh, Apache-2.0, CryptoKit): the SSH
    client (host-key check, key or one-time password sign-in, exec, direct-tcpip), the key store (SshPcs,
    secrets sealed with AES-GCM under a Keychain key, this device only), pasted key parsing (OpenSSH ed25519 and
    ECDSA, with a passphrase via bcrypt_pbkdf, PEM ECDSA), the loopback tunnel with Android's lifetime rules
    (SshTunnel), and the PC-side commands, byte for byte Android's.
  • app/ios/App/App: OvisSshPlugin (add, setUp, list, phoneKey, copy, share, rename, forgetHostKey,
    remove), the SwiftUI setup screen (SshSetupView), SshWords (made from Android's ssh_strings.xml en/ko),
    HerdrShell.openSshSetup/takeSshSetup (hosted Direct tab handoff), the failure kind and command for
    error.html, foreground wake and network-change drop.

Security (for t13r)

  • Host keys: nothing is sent to an unconfirmed host (the first connect is refused at the host-key step and
    only shows the SHA-256 fingerprint); a saved key is pinned with its algorithm and any other fails closed;
    only Manage → Forget host key lets a new one in.
  • Loopback: iOS has only 127.0.0.1, so each PC gets its own port (47320 to 47619). The gate cookie is named
    for the port (ovis_ssh_gate_<port>, 256 random bits, HttpOnly, SameSite=Strict, host-only); every
    ovis_ssh_gate_* cookie (the WebView sends all PCs' gates to each port) is stripped before the request goes on, compared in constant time. Because cookies do not separate ports, the tunnel
    also refuses any request with a foreign Origin or a Sec-Fetch-Site other than same-origin/none
    (another SSH PC's page is same-site). The app never opens or navigates to 127.0.0.1 at a port no SSH PC
    listens on, and the tunnel refuses a redirect there.
  • Capacitor iOS lets any page call any plugin: DirectCallGate drops every OvisSsh message not from the
    main frame of capacitor://localhost; the plugin also refuses calls while a PC page is up.
  • Secrets: phone key (ed25519), pasted key, passphrase and gate are sealed (AES-GCM, Keychain key with
    kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly); a password is used once and never stored; the key it
    registers is proven by signing in with it before the screen finishes.
  • authorized_keys edits are Android's commands, with the same input checks (key line and blob charset).

Also in this PR (owner, 0.5.10, both apps)

  • Tailscale SSH with no key (auth "tailscale"): SSH none sign-in; Tailscale's check-mode banner link
    (only https://login.tailscale.com/...) is shown with Open the link during setup (10 min wait); a reconnect that
    needs a check fails with tailscale-check and error.html offers the link. Host key still confirmed and pinned.
  • The PCs a first PC knows: OvisSsh.known reads an SSH PC's own /api/machines/ssh-candidates and
    /api/machines over its tunnel (local access); the SSH tab lists them (knownLogins) with Add, which opens
    the SSH setup prefilled. Nothing connects by itself.

Differences from Android

  • No RSA private key paste (SwiftNIO SSH has no RSA); said in words. Password sign-in uses SSH's password
    method only (no keyboard-interactive). No FLAG_SECURE equivalent on the setup screen.

Validation

  • swift test in app/ios/OvisSshCore on eamac: 62 tests pass (unit + a real user sshd fixture incl. a Tailscale-style
    banner + one against a real Tailscale SSH server, which handed over its check link).
  • Android: ./gradlew :app:testDebugUnitTest --tests 'sh.ovis.app.Ssh*' :app:assembleDebug on eamac: 58 pass, build OK.
  • bun test scripts/app-shell.test.ts: 31 pass. bun run check fast: typecheck, build, generated ok; unit 22717 pass,
    1 fail = server/ssh-account-add.test.ts, which fails only with a long TMPDIR (socket path > 108 bytes) and passes
    with a short one (3/3), untouched here.
  • iOS Simulator (eamac, iPhone 18 Pro, iOS 27, WebDriverAgent): user@host → setup screen → phone key line → host-key
    fingerprint matches ssh-keygen → PC page opens over the tunnel (no gate cookie reached the PC, Connection: close)
    → relaunch reopens it; SSH tab lists the PCs the first PC knows; Add → Tailscale SSH preselected → real Tailscale
    check link shown.
  • Android emulator (eamac, Android 16): the same SSH add and open, known-PCs list, Add → Tailscale preselected → check link shown.
  • Not run: approving a Tailscale check to the end (it would open the maintainer's live Ovis); a real iPhone.
  • Reviews: t13r (security-triage) YES at c34534e and YES on the later diff; dori review findings (gate cookies HIGH,
    four LOWs) fixed.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@devswha

devswha commented Nov 21, 2026

Copy link
Copy Markdown
Owner Author

Hold: the full add-a-PC flow in the iOS Simulator (WebDriverAgent) is still to run; eamac's Xcode needs an administrator to install its CoreSimulator update first. Security review by security-triage (t13r) requested.

@devswha devswha added the hold Not merged until the owner says so label Nov 21, 2026
@devswha devswha removed the hold Not merged until the owner says so label Nov 21, 2026
… a Tailscale check stops until Try again; review follow-ups
@devswha
devswha merged commit ecd347a into release/relay-0510 Nov 21, 2026
15 checks passed
@devswha
devswha deleted the feat/ios-phone-ssh branch November 21, 2026 23:28
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