1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-18 15:20:56 +03:00
Commit Graph

29 Commits

Author SHA1 Message Date
dependabot[bot]
45d52d16c3 GHA: bump components
- bump debian from `c99c733` to `1caf1c7` in /tests/openssh_server
- bump github/codeql-action from 4.30.7 to 4.30.8

Closes #1726
Closes #1725
2025-10-14 03:24:42 +02:00
Viktor Szakats
d223094467 Dockerfile: pin Debian trixie image, enable Dependabot
- pin Debian trixie Docker image to hash.
- set Dependabot to update the pin once every month.
- set Dependabot commit message prefixes to `GHA:` (to match curl).

Closes #1724
2025-10-14 02:39:15 +02:00
Viktor Szakats
4f9e6e0bfb REUSE: add copyright headers to more files, and .gitignore updates
Also:
- rename a spellcheck file to match curl.
- editorconfig: fix line width.
- editorconfig: make it use UTF-8.
- editroconfig: apply some rules to all files.
- .gitignore: drop dupe, drop `.DS_Store` (not created by this repo),
   sort.
- .gitignore: add for tests executables.

Closes #1718
2025-10-13 13:35:25 +02:00
Viktor Szakats
f89406b50c Dockerfile: switch to Debian stable
To avoid failing tests in job
'linux (clang, i386, Libgcrypt, autotools, ON, --disable-static)'.
Same job with x86_64 or OpenSSL did pass without issues.

Example:
https://github.com/libssh2/libssh2/actions/runs/14703383105/job/41758988183?pr=1588
```
libssh2_session_handshake failed (-5): Unable to exchange encryption keys
```

Bug: https://github.com/libssh2/libssh2/pull/1591#issuecomment-2844417405
Fix-suggested-by: Jacob Barthelmeh
Fixes #1594
Closes #1595
2025-05-07 01:04:57 +02:00
Viktor Szakats
b7ab0faa70 disable DSA by default
Also:
- add `LIBSSH2_DSA_ENABLE` to enable it explicitly.
- test the above option in CI.
- say 'deprecated' in docs and public header.
- disable DSA in the CI server config.
  (OpenSSH 9.8 no longer builds with it by default)
  https://www.openssh.com/txt/release-9.8
  Patch-by: Jose Quaresma
- disable more DSA code when not enabled.

Fixes #1433
Closes #1435
2024-07-30 22:59:02 +02:00
Viktor Szakats
839bb84e89 ci/GHA: fix Dockerfile failing after Ubuntu package update
Likely due an upstream Ubuntu package update (requiring an apt-get
install call beforehand), tests run via autotools started failing with
no change in the libssh2 repo:
```
FAIL: test_aa_warmup
====================

Error running command 'docker build --quiet -t libssh2/openssh_server %s' (exit 256): Dockerfile:10
--------------------
   8 |      && apt-get clean \
   9 |      && rm -rf /var/lib/apt/lists/*
  10 | >>> RUN mkdir /var/run/sshd
  11 |
  12 |     # Chmodding because, when building on Windows, files are copied in with
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /var/run/sshd" did not complete successfully: exit code: 1

Failed to build docker image
Cannot stop session - none started
Cannot stop container - none started
Command: docker build --quiet -t libssh2/openssh_server ../../tests/openssh_server
FAIL test_aa_warmup (exit status: 1)
```
Ref: https://github.com/libssh2/libssh2/actions/runs/9322194756/job/25662748095#step:11:390

Fix it by skipping `mkdir` if `/var/run/sshd` already exists.

(Why cmake-based jobs aren't affected, I don't know.)

Ref: 50143d5867 (commitcomment-142560875)
Closes #1400
2024-05-31 21:21:30 +02:00
Viktor Szakats
1d815d666c test debian:testing-slim post xz backdoor removal (#1346)
The unexplained CI fallouts are gone with the latest debian:testing (20240330).

Ref #1328 #1329 #1338.
Closes #1346
2024-04-02 21:52:23 +02:00
Viktor Szakats
97aa8388aa Dockerfile: switch to Debian stable (from testing)
This fixes flakiness experienced recently with two OpenSSL jobs and one
libgcrypt job, and/or intermittently causing all Docker-based tests to
fail.

Reported-by: András Fekete
Fixes #1328
Fixes #1329
Closes #1338
2024-03-28 22:18:45 +00:00
Viktor Szakats
b9a4ed83b4 reuse: fix duplicate copyright warning
```
PendingDeprecationWarning:
Copyright and licensing information for 'tests/openssh_server/Dockerfile'
has been found in both 'tests/openssh_server/Dockerfile' and in the DEP5
file located at '.reuse/dep5'. The information for these two sources has
been aggregated. In the future this behaviour will change, and you will
need to explicitly enable aggregation. [...]
```
Ref: https://github.com/libssh2/libssh2/actions/runs/6789274955/job/18456085964#step:4:4
2023-11-08 03:52:45 +00:00
Viktor Szakats
5754fed686 ci: replace mv + chmod with install in Dockerfile
Cherry-picked from #1175
Closes #1175
2023-08-23 11:05:56 +00:00
Viktor Szakats
e61987a3bf tests: formatting and tidy-ups
- Dockerfile: use standard sep with `sed`
- Dockerfile: use single quotes in shell command
- appveyor.yml: use long-form option with `choco`
- tests/cmake: add language to test project
- reuse.yml: fix indentation
  ```
  $ yamllint reuse.yml
  reuse.yml
    [...]
    11:5      error    wrong indentation: expected 6 but found 4  (indentation)
    15:5      error    wrong indentation: expected 6 but found 4  (indentation)
    [...]
    27:5      error    wrong indentation: expected 6 but found 4  (indentation)
  ```

Cherry-picked from #1175
2023-08-23 10:53:53 +00:00
Viktor Szakats
76307435b8 tidy-up: delete duplicate word from comment 2023-08-02 23:04:43 +00:00
Viktor Szakats
802336cf95 tests: add aes256-gcm encrypted key test
Follow-up to #1133

Also update `tests/gen_keys.sh` to set `aes256-ctr` encryption method
for `key_ed25519_encrypted' explicitly.

Closes #1135
2023-07-26 07:17:29 +00:00
Viktor Szakats
fe6239a11f reuse: comply with 3.1 spec and 2.0.0 checker
The checker tool was upgraded upstream to 2.0.0 and the REUSE
Specification to version 3.1 (from 3.0), causing these new errors:
```
reuse.project - WARNING - Copyright and licensing information for 'docs/INSTALL_AUTOTOOLS' have been found in 'docs/INSTALL_AUTOTOOLS' and the DEP5 file located at '.reuse/dep5'. The information in the DEP5 file has been overridden. Please ensure that this is correct.
reuse.project - WARNING - Copyright and licensing information for 'tests/openssh_server/Dockerfile' have been found in 'tests/openssh_server/Dockerfile' and the DEP5 file located at '.reuse/dep5'. The information in the DEP5 file has been overridden. Please ensure that this is correct.

The following files have no licensing information:
* docs/INSTALL_AUTOTOOLS
* tests/openssh_server/Dockerfile
```
Via: https://github.com/libssh2/libssh2/actions/runs/5333572682/jobs/9664211341?pr=1098#step:4:4

Ref: https://github.com/fsfe/reuse-tool/releases/tag/v2.0.0
Ref: https://git.fsfe.org/reuse/docs/src/branch/stable/CHANGELOG.md#3-1-2023-06-21

Original discovery: https://github.com/libssh2/libssh2/pull/1098#issuecomment-1600719575

Fixes #1101
Closes #1102
2023-06-21 17:43:42 +00:00
Viktor Szakats
187d89bb07 copyright: remove years from copyright headers
Also:
- uppercase `(C)`.
- add missing 'All rights reserved.' lines.
- drop duplicate 'Author' lines.
- add copyright headers where missing.
- enable copyright header check in checksrc.

Reasons for deleting years (copied as-is from curl):
- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- saves us from pointless churn
- git keeps history for us
- the year range is kept in COPYING

Closes #1082
2023-06-04 19:19:16 +00:00
Viktor Szakats
33f3260a4a tests: fix newlines in test keys for sshd on Windows
Make sure these files get LF newlines on checkout. Before this patch
a checked out libssh2 Git repository may have used CRLF newlines in text
files, include test keys. Private keys with CRLF newlines could confuse
sshd on Windows:

```
# sshd version: 'OpenSSH_9.2, OpenSSL 1.1.1t  7 Feb 2023'
Unable to load host key "/d/a/libssh2/libssh2/tests/openssh_server/ssh_host_ed25519_key": invalid format
Unable to load host key: /d/a/libssh2/libssh2/tests/openssh_server/ssh_host_ed25519_key
```
Ref: https://github.com/libssh2/libssh2/actions/runs/4846188677/jobs/8635575847#step:6:39

Cherry-picked from #1017
2023-05-03 01:45:59 +00:00
Viktor Szakats
2c18b6fc8d build: fix make distcheck regressions
- add #included C files to `EXTRA_DIST`.

  Regression from 4f0f4bff5a

- fix `tests/sshd_fixture.sh` to not write into the test dir, by using
  a pre-assembled `TrustedUserCAKeys` file. Update `Dockerfile` too to
  use this.

  Regression from a459a25302

Also update `tests/sshd_fixture.sh` to use
`openssh_server/authorized_keys` like `Dockerfile` does. And a few more
cosmetic updates.

Closes #1006
2023-04-26 16:46:11 +00:00
Viktor Szakats
a459a25302 tests: improve running tests
TL;DR: Sync test builds between autotools and CMake. Sync sshd
configuration between Docker and non-Docker fixtures. Bump up
sshd_config for recent OpenSSH releases.

This also opens up the path to have non-Docker tests that use a
local sshd process. Though sshd is practically unusable on Windows
CI machines out of the box, so this will need further efforts.

Details:

- cmake: run sshd fixture test just like autotool did already.

- sync tests and their order between autotools and CMake.

  It makes `test_aa_warmup` the first test with both.

- cmake: load test lists from `Makefile.am`.

  Needed to update the loader to throw away certain lines to keep the
  converted output conform CMake syntax. Using regexp might be an
  alternative way of doing this, but couldn't make it work.

- cmake: use the official way to configure test environment variables.
  Switch to syntax that's extendable.

- cmake: allow to run the same test both under Docker and sshd fixture.

  Useful for testing the sshd fixture runner, or how the same test
  behaves in each fixture.

- update test fixture to read the username from `USER` envvar instead of
  using the Dockfile-specific hardwired one, when running outside Docker.

- rework `ssh2.sh` into `sshd_fixture.sh`, to:

  - allow running any tests (not just `test_ssh2`).
  - configure Docker tests for running outside Docker.
  - fixup `SSHD` path when running on Windows (e.g. in AppVeyor CI).
    Fixes: `sshd re-exec requires execution with an absolute path`
  - allow overriding `PUBKEY` and `PRIVKEY` envvars.
  - allow overriding `ssh_config` via `SSHD_FIXTURE_CONFIG`.

- prepare support for running multiple tests via sshd_fixture.

  Add a TAP runner for autotools and extend CMake logic. The TAP runner
  loads the test list from `Makefile.am`.

  Notice however that on Windows, `sshd_fixture.sh` is very flaky with
  GitHub Actions. And consistently broken for subsequent tests in
  AppVeyor CI:
    'libssh2_session_handshake failed (-43): Failed getting banner'

  Another way to try is a single sshd instance serving all tests.
  For CMake this would probably mean using an external script.

- ed25519 test keys were identical for auth and host. Regenerate the
  auth keypair to make them distinct.

- sync the sshd environment between Docker and sshd_fixture.

  - use common via `openssh_server/sshd_config`.
  - accept same auth keys.
  - offer the same host keys.
  - sync TrustedUserCAKeys.
  - delete now unused keypairs: `etc/host*`, `etc/user*`.
  - bump up startup delay for Windows (randomly, to 5 secs, from 3).
  - delete `UsePrivilegeSeparation no` to avoid deprecation warnings.
    `command-line line 0: Deprecated option UsePrivilegeSeparation`
  - delete `Protocol 2` to avoid deprecation warnings.
    It has been the default since OpenSSH 3.0 (2001-11-06).
  - delete `StrictModes no` (CI tests work without it, Docker tests
    never used it).

- bump `Dockerfile` base image to `testing-slim` (from `bullseye-slim`).

  It needed `sshd_config` updates to keep things working with
  OpenSSH 9.2 (compared to bullseye's 8.4).

  - replace `ChallengeResponseAuthentication` alias with
    `KbdInteractiveAuthentication`.
    The former is no longer present in default `sshd_config` since
    OpenSSH 8.7 (2021-08-20). This broke the `Dockerfile` script.
    The new name is documented since OpenSSH 4.9 (2008-03-31)

  - add `PubkeyAcceptedKeyTypes +ssh-rsa,ssh-dss,ssh-rsa-cert-v01@openssh.com`
    and `HostKeyAlgorithms +ssh-rsa`.

    Original-patch-by: Eric van Gyzen (@vangyzen on github)
    Fixes #691

    There is a new name for `PubkeyAcceptedKeyTypes`:
       `PubkeyAcceptedAlgorithms`.
    It requires OpenSSH 8.5 (2021-03-03) and breaks some envs so we're
    not using it just yet.

- drop `rijndael-cbc@lysator.liu.se` tests and references from config.

  This is a draft alias for `aes256-cbc`. No need to test it twice.
  Also this alias is no longer recognized by OpenSSH 8.5 (2021-03-03).

- update `mansyntax.sh` and `sshd_fixture.sh` to not rely on `srcdir`.

  Hopefully this works with out-of-tree builds.

- fix `test_read_algos.test` to honor CRLF EOLs in their inputs
  (necessary when running on Windows.)

- fix `test_read_algos.test` to honor `EXEEXT`. Might be useful when
  running tests under cross-builds?

- `test_ssh2.c`:

  - use libssh2 API to set blocking mode. This makes it support all
    platforms.
  - adapt socket open timeout logic from `openssh_fixture.c`.
    Sadly this did not help fix flakiness on GHA Windows.

- tests: delete unused C headers and variable initialization.

- delete unused test files: `sshd_fixture.sh.in`, `sshdwrap`,
  `etc/sshd_config`.

  Ref: cf80f2f4b5

- autotools: delete stray `.c` test sources from `EXTRA_DIST` in tests.

- `tests/.gitignore`: drop two stray tests.

- autotools: fix passing `SSHD` containing space (Windows needs this).

- autotools: sort `EXTRA_DIST` in tests.

- cmake: fix to add `test_ssh2` to `TEST_TARGETS`.

- fix `authorized_key` order in `tests/gen_keys.sh`.

- silence shellcheck warning in `ci/checksrc.sh`.

- set `SSHD` for autotools on GitHub Actions Windows. [skipped]

  Auto-detection doesn't work (maybe because sshd is installed via
  Git for Windows and we're using MSYS2's shell.)

  It enables running sshd fixture (non-Docker) tests in these jobs.

  I did not include this in the final patch due to flakiness:
  ```
  Connection to 127.0.0.1:4711 attempt #0 failed: retrying...
  Connection to 127.0.0.1:4711 attempt #1 failed: retrying...
  Connection to 127.0.0.1:4711 attempt #2 failed: retrying...
  Failure establishing SSH session: -43
  ```

  Can be enabled with:
  `export SSHD='C:/Program Files/Git/usr/bin/sshd.exe'`

Closes #996
2023-04-24 21:28:28 +00:00
Viktor Szakats
fe64bad58f tests: switch to debian:bullseye-slim in Dockerfile
'slim' provides all we need, with less bloat.

Tested in #976

Follow-up to 78cb64a859
2023-04-16 22:50:40 +00:00
Viktor Szakats
819573f94e tests: restore debian:bullseye in Dockerfile
Follow-up to 78cb64a859
2023-04-16 17:08:16 +00:00
Viktor Szakats
c9160bf89c tests: try debian:testing for Dockerfile
Follow-up to 78cb64a859
2023-04-16 16:16:18 +00:00
Viktor Szakats
78cb64a859 tests: switch Dockerfile to debian:testing-slim
From debian:bullseye

- doesn't need manual bumps.
- is ahead of stable and should be stable enough for our purpose.
- slim is saving resources.

Closes #971
2023-04-16 15:43:43 +00:00
Dan Fandrich
7487dcf4b4 Add tests to check individual crypt & HMAC methods
One specific crypt or hmac method is requested to be negotiated, then
several MB of data is transferred.
2023-03-01 11:21:39 -08:00
Sandeep Bansal
4b21e49d9d Support RSA certificate authentication (#710)
* Adding support for signed RSA keys and unit test

Credit:
Sandeep Bansal
2022-07-28 08:57:34 -07:00
kkoenig
3f9d505353 Support ECDSA certificate authentication (#570)
Files: hostkey.c, userauth.c, test_public_key_auth_succeeds_with_correct_ecdsa_key.c

Notes:
Support ECDSA certificate authentication

Add a test for:
  - Existing ecdsa basic public key authentication
  - ecdsa public key authentication with a signed public key

Credit:
kkoenig
2021-05-12 09:13:19 -07:00
Will Cosgrove
0309229259 ED25519 Key Support #39 (#248)
OpenSSH Key and ED25519 support #39
Added _libssh2_explicit_zero() to explicitly zero sensitive data in memory #120

* ED25519 Key file support - Requires OpenSSL 1.1.1 or later
* OpenSSH Key format reading support - Supports RSA/DSA/ECDSA/ED25519 types
* New string buffer reading functions - These add build-in bounds checking and convenance methods. Used for OpenSSL PEM file reading.
* Added new tests for OpenSSH formatted Keys
2018-08-02 14:00:25 -07:00
Will Cosgrove
aba34f5f56 Add support for ECDSA keys and host keys (#41)
This commit lands full ECDSA key support when using the OpenSSL
backend. Which includes:

New KEX methods:
ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521

Can now read OpenSSL formatted ECDSA key files.

Now supports known host keys of type ecdsa-sha2-nistp256.

New curve types:
NID_X9_62_prime256v1, NID_secp384r1, NID_secp521r1

Default host key preferred ordering is now nistp256, nistp384,
nistp521, rsa, dss.

Ref: https://github.com/libssh2/libssh2/issues/41

Closes https://github.com/libssh2/libssh2/pull/206
2018-03-09 19:28:38 +00:00
Marc Hoersken
323aa08f01 tests/openssh_server/authorized_keys: add key_rsa_encrypted.pub 2017-03-02 22:29:14 +01:00
Alexander Lamaison
cf80f2f4b5 Basic dockerised test suite.
This introduces a test suite for libssh2. It runs OpenSSH in a Docker
container because that works well on Windows (via docker-machine) as
well as Linux. Presumably it works on Mac too with docker-machine, but
I've not tested that.

Because the test suite is docker-machine aware, you can also run it
against a cloud provider, for more realistic network testing, by setting
your cloud provider as your active docker machine. The Appveyor CI setup
in this commit does that because Appveyor doesn't support docker
locally.
2016-08-14 16:03:25 +01:00