Skip to content

SSH on libssh for iOS and Android (sshj and SwiftNIO SSH gone) - #48

Merged
Neo-Desktop merged 3 commits into
mainfrom
claude/project-thread-eywog3
Nov 12, 2026
Merged

Neo-Desktop merged 3 commits into
mainfrom
claude/project-thread-eywog3

Conversation

@Neo-Desktop

Copy link
Copy Markdown
Collaborator

Requested by Sydney · project thread

What

Both apps' SSH now runs on the same client as the desktop GUI (D-Modem/gui#10): libdmodemssh (native-ssh/), on libssh 0.11 with its own Mbed TLS. Both are built from release tarballs pinned by SHA-256.

  • iOS: DModemSSH wraps the engine, built as the DModemSSHNative XCFramework by ios/build-native.sh. Only dmc_ssh_* is exported, so its Mbed TLS can't clash with libre's. SwiftNIO SSH is gone. Password, keyboard-interactive and key logins work, with Ed25519, ECDSA and RSA keys.

  • Android: the engine loads through JNI as libdmodem_ssh_jni.so (NativeSsh.kt), and sshj is gone. The features carry over:

    • the app's own keys, made here or imported (OpenSSH, PEM, PuTTY .ppk v2/v3)
    • saved passwords and keyboard-interactive logins
    • known hosts
    • port forwards: -L, -R, and -D (SOCKS 4/4a/5)
    • agent forwarding, with a confirmation per signature
    • ssh-copy-id

    BouncyCastle stays for the key maths.

  • Engine changes, mirrored on gui#10:

    • Commands can forward the agent.
    • A write reports how many bytes are still queued, so forwards hold back a fast sender.
    • libssh is built WITH_SERVER, because its client-side callbacks for server-opened channels (the agent's) only run then.
    • PatchLibssh.cmake fixes libssh's remote listen on port 0. libssh read the bound port from the last packet received, so a listen the server had accepted could fail at random.

Tests

  • native-ssh/test passes against a real sshd: password, key, shell, exec, -L, -R and refused host keys. CI's native job runs it, then the DModemSSH Swift tests.
  • The Android unit tests build the JNI library for the host (buildHostSsh) and run the SSH tests against it. All of these pass locally: SshLinkTest (MINA), OpenSshInteropTest (OpenSSH's sshd and puttygen: forwards, agent hop with RSA, ssh-copy-id, keys both ways), and the SSH UI tests. The full testDebugUnitTest run passes too.
  • The arm64 NDK build of libdmodem_ssh_jni.so exports only the Java_* entry points and is 16 KB-page aligned.

Generated by Claude Code

native-ssh is the desktop apps' SSH engine (D-Modem/gui's ssh/), built
here from libssh's and mbedTLS's release tarballs for the host, Android
and Apple's systems.  ios/build-native.sh makes it
DModemSSHNative.xcframework, each arch linked into one object whose only
globals are dmc_ssh_*, so its mbedTLS never meets the engine's.
DModemSSH's SSHShell keeps its API on it (SwiftNIO SSH goes), adding RSA,
keyboard-interactive and private keys; CI runs its tests and the
engine's against a real sshd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
The SSH client is the same as iOS's and the GUI's now: native-ssh, on
libssh, loaded as libdmodem_ssh_jni.so (NativeSsh.kt). SshLink polls
it on its own thread; its channels carry the shell, commands, the
port forwards (-L, -R, -D) and the forwarded agent's requests. Keys
stay the app's: SSH's wire form (SshWire.kt), OpenSSH's and PEM keys
read through the engine, PuTTY's .ppk read here, all on BouncyCastle.

The engine: commands can forward the agent, a write tells what's still
kept for the server (forwards hold back a fast sender), libssh built
WITH_SERVER (its callbacks for the agent's channels need it), and its
remote listen on port 0 patched to take the port from its own reply.

The unit tests build the JNI library for the host (buildHostSsh) and
run against it: OpenSSH's sshd, puttygen and Apache MINA's server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
…sal per slice

Both XCFrameworks' headers land in the app's one include/, so
CDModemSSH's module.modulemap goes in include/CDModemSSH/; each
slice's archive is lipo'd from one archive per arch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
@Neo-Desktop
Neo-Desktop merged commit 48bf218 into main Nov 12, 2026
9 checks passed
@Neo-Desktop
Neo-Desktop deleted the claude/project-thread-eywog3 branch November 12, 2026 14:30
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