Skip to content

tests: dump container sshd log for test failures - #2621

Closed
vszakats wants to merge 21 commits into
libssh2:masterfrom
vszakats:docker-logs
Closed

vszakats wants to merge 21 commits into
libssh2:masterfrom
vszakats:docker-logs

Conversation

@vszakats

@vszakats vszakats commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

To help debugging issues.

Also:

  • bump sshd LogLevel to DEBUG1, for essential details.
  • bump command output buffer in run_command_varg()
  • drop redundant condition in run_command_varg()
  • replace BUFSIZ with literal sizes in run_command_varg().

After this patch it's showing this in the CI log for the libgcrypt
fallout that previously needed a long time to diagnose:

61: ---- sshd log ----
61: No matching private key for certificate: /etc/ssh/ssh_host_mldsa44-ed25519_key-cert.pub
61: Server listening on 0.0.0.0 port 22.
61: Server listening on :: port 22.
61: debug1: sshd-session version OpenSSH_10.5, OpenSSL 3.6.3 9 Jun 2026
61: Connection from 172.17.0.1 port 51878 on 172.17.0.2 port 22 rdomain ""
61: debug1: sshd-auth version OpenSSH_10.5, OpenSSL 3.6.3 9 Jun 2026 [preauth]
61: debug1: list_hostkey_types: rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],
[email protected],[email protected],ecdsa-sha2-nistp256,
[email protected],ssh-ed25519,[email protected] [preauth]
61: debug1: Local version string SSH-2.0-OpenSSH_10.5p1 Debian-1 [preauth]
61: debug1: Remote protocol version 2.0, remote software version libssh2_1.11.2_DEV [preauth]
61: debug1: compat_banner: no match: libssh2_1.11.2_DEV [preauth]
61: debug1: SSH2_MSG_KEXINIT sent [preauth]
61: debug1: SSH2_MSG_KEXINIT received [preauth]
61: debug1: kex: algorithm: (no match) [preauth]
61: Unable to negotiate with 172.17.0.1 port 51878: no matching key exchange method found.
Their offer: diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,
diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,
diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1,ext-info-c,
[email protected] [preauth]
[...]
61: ------------------

Follow-up to 1d0b86a #2484
Follow-up to 8be5716 #2174
Follow-up to 51f6259 #1720

@vszakats
vszakats marked this pull request as draft September 13, 2026 16:19
@vszakats vszakats changed the title tests: dump container sshd log on test failure tests: dump container sshd log for test failures Sep 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Local-sshd failures can invoke an invalid container command, logs may be truncated, and the advertised debug flags are missing.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds failed-test diagnostics by dumping containerized sshd logs during fixture teardown.

Changes:

  • Propagates test exit status through fixture cleanup.
  • Dumps sshd logs when tests fail.
  • Comments out an existing KEX compatibility setting.
File summaries
File Description
tests/session_fixture.h Updates fixture teardown signature.
tests/session_fixture.c Forwards test status to OpenSSH cleanup.
tests/runner.c Passes test result during teardown.
tests/openssh_server/sshd_config Disables explicit DH KEX configuration.
tests/openssh_fixture.h Updates OpenSSH teardown signature.
tests/openssh_fixture.c Adds failed-test log collection.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/openssh_fixture.c Resolved
Comment thread tests/openssh_fixture.c Resolved
Comment thread tests/openssh_server/sshd_config Resolved
Comment thread tests/openssh_fixture.c Resolved
@vszakats

vszakats commented Sep 13, 2026 •

Copy link
Copy Markdown
Member Author

Linux tests, which are expected to succeed all (except libgcrypt), are now stalling
at test 31: test_exit_status.
https://github.com/libssh2/libssh2/actions/runs/34768234376/job/103752967110

edit: triggered by -dd in containerized sshd. By replacing it with a comment
update in Dockerfile, it's fine again:
https://github.com/libssh2/libssh2/actions/runs/34773718505/job/103767857274?pr=2621

edit 2: also triggered by -d.
https://github.com/libssh2/libssh2/actions/runs/34774441036/job/103769837608?pr=2621

edit 3: same with -d + 2 MiB output buffer:
https://github.com/libssh2/libssh2/actions/runs/34775094365/job/103771686325?pr=2621

edit 4: hah, obvious: -d makes the server be a one-shot, and the container exited
after the run session was over. Hence neither logs nor stop worked. Why this
caused a hang with 31 I don't know, but going with sshd_config LogLevel instead.

@vszakats
vszakats marked this pull request as ready for review September 13, 2026 18:51
@vszakats vszakats added the tests label Sep 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Auto-removal makes logs unavailable for failures where the sshd container exits before teardown.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread tests/openssh_fixture.c
Comment on lines +477 to +478
if(exit_code)
openssh_server_dump_logs(running_container_id);

@vszakats vszakats Sep 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I've suffered through this, but aside from re-introducing this issue manually, by letting sshd exit prematurely, I don't think we should redesign everything around such an event. Pass.

@vszakats vszakats closed this in 45aa5c5 Sep 13, 2026
@vszakats
vszakats deleted the docker-logs branch September 13, 2026 19:21
vszakats added a commit that referenced this pull request Oct 4, 2026
To silence a warning, in rare failure cases:
```
srclimit_penalise: ipv4: new 172.17.0.1/32 deferred penalty of 1.000
  seconds for penalty: connections without attempting authentication
```
Ref: https://github.com/libssh2/libssh2/actions/runs/37207427612/job/111451438515?pr=2649#step:25:537

Also:
- seize the opportunity and bump sshd debug level to 2.
  Level 1 is too low to see clearly in some cases.
  Ref: #2649
  Follow-up to 45aa5c5 #2621

Refs:
https://man.openbsd.org/sshd_config#PerSourcePenalties
https://www.openssh.org/txt/release-9.8

Closes #2650
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants