Skip to content

Built-in SSH on libssh for every desktop app - #10

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

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

Conversation

@Neo-Desktop

Copy link
Copy Markdown
Contributor

Requested by Sydney · project thread

SSH on the Remote page no longer depends on a system ssh. It goes through libdmodemssh (ssh/), D-Modem's own SSH client on libssh 0.11. The Android and iOS apps will use the same engine, so SSH works the same on every platform.

libdmodemssh (ssh/include/dmodemssh.h, ssh/src/dmodemssh.c)

  • One thread per connection polls it. Other threads can type, resize and answer questions at any time, because every call takes a lock.
  • The caller decides on the host key. When asked, it also checks and updates OpenSSH's known_hosts, and it can read ~/.ssh/config.
  • Logins: password, keyboard-interactive, a private key passed as text, the agent, or OpenSSH's default keys and agent together.
  • Ed25519, ECDSA and RSA keys.
  • Channels: a shell on a pty, commands, direct TCP (-L/-D), remote listens (-R), and agent channels from the server (-A).
  • Keys can be generated, read and re-encrypted (OpenSSH format).
  • libssh and mbedTLS come from the system's libssh when it is 0.11 or newer. Otherwise they are built from their release tarballs, checked by SHA-256. Windows and macOS always build them. mbedTLS is patched to enable threading, which libssh needs.

Apps

  • Linux: a GThread polls the connection and events go back with g_main_context_invoke. A new server's key is shown with its SHA256 fingerprint in an AdwAlertDialog and added to known_hosts if accepted. A changed key is refused with a warning. Passwords and the server's questions are asked in dialogs. The forkpty and system ssh code is removed.
  • Windows (MinGW/MSVC): a thread posts WM_APP_SSH. There is a new IDD_ASK login dialog that sizes itself to the number of questions. Known hosts are kept in the profile's .ssh. The Open Watcom (Windows 95) build has no libssh, so it keeps the ConPTY + ssh.exe path.
  • macOS: SSHConnection.swift polls on a thread and hands events to the main queue, with SwiftUI alerts for the questions. PtySpawn.c is removed. The repository's CMake builds libssh universal (arm64 and x86_64) for the Xcode project.

CI: the Linux job now starts a real sshd and runs the SSH tests against it (password, key, shell, command, -L, -R). The macOS job builds libssh universal.

Tested

  • dmodemssh_test against a local OpenSSH server, on Linux and as the MinGW build under Wine. Covered: host key refusal, a wrong then a right password, an RSA key login, keyboard-interactive (on a PAM sshd), a shell's stty size/TERM/exit status, a command with stdin, EOF and exit status, a direct channel, and a remote listen on a port the server picks, with data both ways. valgrind reports nothing.
  • Linux app under Xvfb: the new-server dialog, known_hosts written, the password dialog, a login with the right size and TERM, and "the shell exited with status 3".
  • Windows app (MinGW) under Wine: the host-key prompt, the login dialog, a shell with the right size and TERM, and the key remembered on the next connect.
  • Not run here: MSVC and macOS builds (CI covers them). The SwiftUI page was only type-checked with stubs on Linux.

Generated by Claude Code

One engine in C on libssh 0.11 (with mbedTLS, both built from their
release tarballs where the system has no libssh 0.11): host keys for
the caller to trust (and OpenSSH's known_hosts when asked), logins by
password, keyboard-interactive, a key, the agent or OpenSSH's defaults,
a shell on a pty, commands, direct channels, remote listens and the
server's agent channels; keys made, read and re-encrypted.  Its tests
log in to a real sshd when DMODEM_SSH_TEST names one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
The Remote page's SSH runs libdmodemssh on a thread of its own: OpenSSH's
config, known_hosts, keys and agent are read; a new server's key is asked
about and remembered, a changed one refused; passwords and the server's
questions are asked in dialogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
The Windows app runs libdmodemssh on a thread that posts its events to
the main window, with a login dialog that fits its questions; the
Windows 95 build keeps Windows' ssh.exe in a pseudo console.  The macOS
app's SSHConnection polls it on a thread for the main queue, with
SwiftUI alerts for a new host, a password or the server's questions;
PtySpawn goes.  libssh and mbedTLS are built universal for macOS by the
repository's CMake.  Linux CI logs in to a real sshd; docs follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
dmc_ssh_exec() takes ssh -A as the shell does, and dmc_ssh_write()
gives back how many bytes wait for the server's window, so a forward
can hold back a fast sender.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
libssh runs a client's callbacks for the channels the server opens
(the forwarded agent's) only when it's built WITH_SERVER, so it now is.
Its remote listen on port 0 read the port the server picked from the
last packet in, often another one, and failed a listen the server had
taken: PatchLibssh.cmake keeps the port from the reply itself. Each of
the engine's functions has its comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRSV65geuGd6zMt2V6r
SSH's shell asks for the terminal type the picker has, as Telnet and
rlogin do.

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