Skip to content

feat(SSH): wrapper library #5314#5315

Open
aleks-f wants to merge 8 commits intomainfrom
5314-ssh-wrapper-lib
Open

feat(SSH): wrapper library #5314#5315
aleks-f wants to merge 8 commits intomainfrom
5314-ssh-wrapper-lib

Conversation

@aleks-f
Copy link
Copy Markdown
Member

@aleks-f aleks-f commented Apr 13, 2026

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Poco::SSH wrapper library (client/server utilities built on libssh), plus a CppUnit testsuite and a sample CLI client.

Changes:

  • Registers the new SSH component and adds build/packaging files (CMake + Makefiles).
  • Introduces Poco::SSH core APIs: SSHServer, SSHSession, SSHClient, SSHHostKeyManager, SSHChannelStream, and exceptions.
  • Adds a testsuite (SSH-testrunner) and a pocossh sample client.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
components Registers SSH as a top-level component.
SSH/CMakeLists.txt Builds/install/packages the new SSH library and conditionally adds tests/samples.
SSH/Makefile Adds make-based build for PocoSSH and links against libssh.
SSH/cmake/PocoSSHConfig.cmake CMake package config for downstream find_package(PocoSSH).
SSH/dependencies Declares dependency on Foundation.
SSH/include/Poco/SSH/SSH.h Defines export macros and auto-link behavior for the SSH library.
SSH/include/Poco/SSH/SSHChannelStream.h Declares stream wrappers and sshReadLine() helper.
SSH/include/Poco/SSH/SSHClient.h Declares SSH client wrapper API.
SSH/include/Poco/SSH/SSHException.h Declares SSH-specific exception types.
SSH/include/Poco/SSH/SSHHostKeyManager.h Declares host key creation/loading utility.
SSH/include/Poco/SSH/SSHServer.h Declares SSH server wrapper and session tracking.
SSH/include/Poco/SSH/SSHServerConfig.h Declares server configuration struct and auth callback.
SSH/include/Poco/SSH/SSHSession.h Declares server-side session handler base class.
SSH/src/SSHChannelStream.cpp Implements ostream/channel bridge and line reader helper.
SSH/src/SSHClient.cpp Implements the client wrapper (connect/auth/channel).
SSH/src/SSHException.cpp Implements SSH exception classes.
SSH/src/SSHHostKeyManager.cpp Implements Ed25519 host key generation/validation.
SSH/src/SSHServer.cpp Implements server listen/accept loop, shutdown, and session tracking.
SSH/src/SSHSession.cpp Implements key exchange, authentication, channel negotiation, and cleanup.
SSH/samples/CMakeLists.txt Adds SSH sample(s) to the build.
SSH/samples/pocossh/CMakeLists.txt Builds the pocossh sample client.
SSH/samples/pocossh/Makefile Make-based build for pocossh sample.
SSH/samples/pocossh/src/pocossh.cpp Adds an interactive SSH CLI client sample.
SSH/testsuite/CMakeLists.txt Adds CTest integration for SSH tests.
SSH/testsuite/Makefile Make-based build for SSH testsuite runner.
SSH/testsuite/src/Driver.cpp Adds console test runner main() for SSH tests.
SSH/testsuite/src/SSHTest.cpp Adds integration-style tests for server/client/auth/channel behavior.
SSH/testsuite/src/SSHTest.h Declares SSH test case class.
SSH/testsuite/src/SSHTestSuite.cpp Defines SSH test suite composition.
SSH/testsuite/src/SSHTestSuite.h Declares SSH test suite entry point.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread SSH/src/SSHServer.cpp
Comment thread SSH/src/SSHClient.cpp
Comment thread SSH/testsuite/src/SSHTest.cpp
Comment thread SSH/src/SSHSession.cpp
Comment thread SSH/src/SSHServer.cpp Outdated
Comment thread SSH/src/SSHSession.cpp
Comment thread SSH/testsuite/src/SSHTest.cpp Outdated
Comment thread SSH/testsuite/src/Driver.cpp
Comment thread SSH/src/SSHHostKeyManager.cpp
Comment thread SSH/src/SSHChannelStream.cpp
@aleks-f aleks-f linked an issue Apr 13, 2026 that may be closed by this pull request
@aleks-f aleks-f added this to the Release 1.16.0 milestone Apr 13, 2026
@aleks-f aleks-f requested a review from matejk April 14, 2026 10:05
aleks-f and others added 8 commits April 20, 2026 21:38
Use pkg-config on Darwin to locate libssh headers/libs,
replace deprecated ssh_pki_generate with ssh_pki_generate_key
(libssh >= 0.11), and fix accept loop hang on macOS by using
poll() instead of relying on shutdown() to unblock accept()
ssh_pki_generate_key was introduced in libssh 0.12.0, not 0.11.0;
correct the version guard so builds against 0.11.x (vcpkg baseline
on windows-2025) fall back to ssh_pki_generate.

On Windows, shutdown() alone does not reliably unblock libssh's
internal poll, so server shutdown with an active session hangs.
Follow shutdown() with closesocket() to force the session's blocking
read to error out and the session thread to exit.
Drop the second Windows OpenSSL distribution (ShiningLight via winget) and
unify on vcpkg. libssh:x64-windows already pulls openssl:x64-windows as a
transitive dependency, so both libraries come from a single tree under
$VCPKG_INSTALLATION_ROOT\installed\x64-windows.

Pre-install step uninstalls any pre-existing libssh/openssl, scrubs
preinstalled OpenSSL/OpenSSH directories from PATH, and deletes orphaned
install dirs so stale runner-image state cannot shadow the vcpkg copy.

Post-install step asserts required headers, libs, and DLLs exist and
locates the legacy provider, mirroring main's FireDaemon validity block.
An explicit DLL-resolution step fails the job if libcrypto-3-x64.dll,
libssl-3-x64.dll, or ssh.dll would resolve from anywhere other than the
vcpkg bin dir.

Post-job cleanup (if: always()) uninstalls both packages so the contract
is explicit even on ephemeral hosted runners.
Switch from a hand-written FindLibSSH.cmake (module mode) to the config
file that libssh installs on every supported platform:

- apt libssh-dev (Debian 12+, Ubuntu): /usr/lib/<triplet>/cmake/libssh/
- brew libssh (macOS): $(brew --prefix libssh)/lib/cmake/libssh/
- vcpkg libssh (Windows): $root/share/libssh/

find_package(libssh CONFIG) exposes an imported target "ssh" which
carries include dirs and link flags. SSH, SSH-testrunner, and pocossh now
link against this target directly; the 73-line cmake/FindLibSSH.cmake is
removed along with its LIBSSH_ROOT_DIR / LIBSSH_INCLUDE_DIRS /
LIBSSH_LIBRARIES conventions.

Windows CI now passes CMAKE_PREFIX_PATH (the config-mode lookup
convention) instead of the obsolete LIBSSH_ROOT_DIR flag.
@matejk matejk force-pushed the 5314-ssh-wrapper-lib branch from 9218b70 to 2398afb Compare April 20, 2026 19:43
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.

SSH wrapper library

3 participants