1502 Commits

Author SHA1 Message Date
Arthur Chan
ebff25b210 OSS-Fuzz: Fix scp fuzzer to avoid local access
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/837>
2026-06-04 16:01:37 +02:00
Sudharshan Hegde
aa3b91a194 config: requestTTY implementation and configuration support with values no/yes/auto/force
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/835>
2026-06-04 16:01:12 +02:00
Arthur Chan
55e729ba91 OSS-Fuzz: Fix blocking of ssh mock session
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/782>
2026-06-01 13:56:49 +02:00
Sudharshan Hegde
97fbcaa492 config: number of password prompts implementation
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/832>
2026-06-01 13:55:08 +02:00
Sudharshan Hegde
e2954fbb76 config: Implement preferredAuthentications option
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/832>
2026-06-01 13:51:05 +02:00
Jakub Jelen
bc3c8181e1 Fix semantics of strchr() for C23
In c23, strchr finally returns const char for const char pointers, which broke
CI after updating to Fedora 44 (gcc 16). The same issue surfaced on tumbleweed.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/830>
2026-05-05 18:29:53 +02:00
Jakub Jelen
23b406f48e tests: Implement code coverage for ssh_userauth_kbdint_getprompt()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/827>
2026-05-05 10:03:17 +02:00
Jakub Jelen
8e82aabc21 tests: Initialize pointers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/827>
2026-05-05 10:03:17 +02:00
Colin Baumgarten
a33da974ef torture_packet: Improve checking of ssh_packet_socket_callback() return value
ssh_packet_socket_callback() will not return error codes like
SSH_ERROR on failure. Instead it will always return an unsigned
size_t value representing the number of bytes which have been
processed.

So adjust the assert in the test accordingly, making sure that all
input bytes have actually been processed.

Signed-off-by: Colin Baumgarten <colin.baumgarten@hubersuhner.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/824>
2026-05-04 16:56:06 +02:00
Nuhiat-Arefin
ad84df197c config: support ChallengeResponseAuthentication as an alias
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:31 +02:00
Nuhiat-Arefin
0670983962 config: make RekeyLimit time argument optional
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:28 +02:00
Nuhiat-Arefin
958e18ba75 options: add OpenSSH PubkeyAuthentication modes
Extend PubkeyAuthentication to support the OpenSSH-compatible modes no, yes/all, unbound, and host-bound.

Preserve the existing enable/disable flag behavior for callers using the legacy API, while also storing the selected mode and keeping the previous integer normalization in ssh_options_set().

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
6386ea5e81 auth: preserve pending publickey auth state
Set the publickey pending call state before the ssh-userauth service request so nonblocking calls can resume cleanly when the first SSH_AUTH_AGAIN happens before the auth request is sent.

Reset pending_call_state on the affected error paths, and only jump straight to the response handler once the auth state shows that the publickey request was already sent.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
e1cb1edddf knownhosts: restrict StrictHostKeyChecking off on key mismatches
Keep the unknown host handling under StrictHostKeyChecking off, including writing accepted keys through to known_hosts.

For changed host keys and different stored key types, do not treat the host as fully trusted. In that path, disable password and keyboard interactive authentication before returning OK.

Apply the same handling in both ssh_is_server_known() and ssh_session_get_known_hosts_entry().

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
3e7e942b77 options: add OpenSSH StrictHostKeyChecking modes
Extend StrictHostKeyChecking from a boolean-style option to the full OpenSSH-compatible mode set: off, yes, ask and accept-new.

Preserve the legacy integer normalization used by ssh_options_set(), document the supported values in the public API, and switch the default to SSH_STRICT_HOSTKEY_ASK.

Known-host handling now recognizes SSH_STRICT_HOSTKEY_ACCEPT_NEW and stores unknown host keys automatically while still rejecting changes.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
84bdb7d9e2 config: require exact boolean tokens
Tighten boolean token handling in config parsing.

For auth-related boolean options, reject unknown tokens instead of silently treating them as false. Keep exact yes/no and true/false handling through ssh_config_get_yesno(), but parse Compression through a dedicated exact token map so it remains limited to yes/no.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/814>
2026-04-30 17:23:12 +02:00
Nuhiat-Arefin
854e9823f5 tests: cover %n and HostName handling
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/811>
2026-04-30 16:45:25 +02:00
Nuhiat-Arefin
77ef6379a5 config: reject too small RekeyLimit values
OpenSSH rejects non zero RekeyLimit data values below 16 bytes. Match that behavior in libssh.

Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:56 +02:00
Nuhiat-Arefin
d157f13b27 config: support ConnectTimeout time values
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:56 +02:00
Nuhiat-Arefin
e34704c203 misc: cap finite timeout conversion at INT_MAX
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:55 +02:00
Nuhiat-Arefin
1dd721b26e config_parser: reject trailing garbage in numeric config values
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:54 +02:00
Nuhiat-Arefin
a9b2831f63 options: validate SSH port values in the 1-65535 range
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/815>
2026-04-30 15:05:53 +02:00
Jakub Jelen
831ceff091 Add missing newline on eof
MacOS is choking on these:

/Users/gitlab/builds/libssh/libssh-mirror/src/packet_cb.c:508:2: error: no newline at end of file [-Werror,-Wnewline-eof]
}
 ^
1 error generated.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/823>
2026-04-28 15:22:19 +02:00
Shreyas Mahajan
627001d441 Test Coverage for PING/Pong
Signed-off-by: Shreyas Mahajan <shreyasmahajan05@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/723>
2026-04-28 09:02:58 +02:00
Nikhil V
068cbd543f config: Allow lowercase suffixes for rekeylimit and ignore trailing
Signed-off-by: Nikhil V <nikhilgreyshines@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/712>
2026-04-24 17:23:35 +02:00
Nikhil V
664e17345b config: Reject invalid suffixes for boolean options and add support for true/false aliases
Signed-off-by: Nikhil V <nikhilgreyshines@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/712>
2026-04-24 17:23:33 +02:00
Nikhil V
b75d2dd46e options: lowercase non-IP implicit hostnames
Signed-off-by: Nikhil V <nikhilgreyshines@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/712>
2026-04-24 17:23:32 +02:00
Nikhil V
69e514ffba options: canonicalize loose IPv4 hostnames
Signed-off-by: Nikhil V <nikhilgreyshines@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/712>
2026-04-24 17:23:31 +02:00
Nikhil V
95d4743bd6 config: Normalize HostName to lowercase and add reproducing corpus
Signed-off-by: Nikhil V <nikhilgreyshines@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/712>
2026-04-24 17:23:30 +02:00
Sudharshan Hegde
933baa889b options: add SSH_OPTIONS_PORT to ssh_options_get_int(), reuse in get_port()
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/809>
2026-04-24 13:49:54 +02:00
Sudharshan Hegde
f6a96322eb config,options: add BatchMode option
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/809>
2026-04-24 13:49:53 +02:00
Sudharshan Hegde
6087bb2738 options: add ssh_options_get_int() generic getter for int/bool options
Signed-off-by: Sudharshan Hegde <sudharshanhegde68@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/809>
2026-04-24 13:49:52 +02:00
Jakub Jelen
458d649594 kex: Allow MLKEM key exchanges in FIPS mode
Based on stale MR !802 and implementation in Fedora OpenSSH

Closes #356

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Pavol Žáčik <pzacik@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/821>
2026-04-24 13:17:18 +02:00
YubarajDas
b2065f71c9 fix: replace str(n)(cat|cpy) with strl(cat|cpy)
Signed-off-by: YubarajDas <dasyubaraj2020@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/796>
2026-04-24 11:11:24 +02:00
Nuhiat-Arefin
1e4ee79ad3 tests: cover Tag and Match tagged parsing
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/806>
2026-04-23 13:36:14 +02:00
Haythem666
dec1c8d8d8 tests: add unit tests for ssh_set_counters()
Signed-off-by: Haythem666 <haythem.farhat@epfl.ch>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/808>
2026-04-09 15:43:08 +02:00
Rui Li
89f6055ec6 tests: add auth flag gate, null session, and options coverage
Signed-off-by: Rui Li <ruili3422@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Merge-Request: <https://gitlab.com/libssh/libssh-mirror/-/merge_requests/792>
2026-04-09 14:40:57 +02:00
ShreyasMahajann
51d715ec91 tests: extend ssh_options_getopt coverage for -q
Signed-off-by: Shreyas Mahajan <shreyasmahajan05@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-04-01 22:15:27 +02:00
Jakub Jelen
527d3b22a1 tests: Add missing newline at the end of file
This is breaking MacOS and FreeBSD builds.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2026-03-30 10:42:48 +02:00
Nuhiat-Arefin
93108dd026 config: add Match version support
Signed-off-by: Nuhiat-Arefin <nuhiatarefin@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-28 19:51:32 +01:00
Mingyuan Li
715d79647d tests: Add dedicated unit tests for getopt abstraction
Add torture_getopt.c with 11 test cases covering basic option parsing,
arguments, optional arguments, unknown options, missing arguments,
BADARG colon behavior, double-dash termination, combined options,
optind advancement, reset behavior, and no-options edge case.
Registered in the unit test CMakeLists.txt.

Signed-off-by: Mingyuan Li <2560359315@qq.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-24 15:11:55 +01:00
Mingyuan Li
90169c598e tests: Enable getopt tests on all platforms
Remove _MSC_VER guards from torture_options_getopt and
torture_options_getopt_o_option so they run unconditionally,
now that a bundled getopt fallback is available.

Signed-off-by: Mingyuan Li <2560359315@qq.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-24 15:11:55 +01:00
Haythem666
01772c4f79 pki: add ssh_key_type_and_hash_from_signature_name()
Merge ssh_key_type_from_signature_name() and ssh_key_hash_from_name()
into a single function ssh_key_type_and_hash_from_signature_name() to:

- Avoid double string comparisons on the same algorithm name
- Return SSH_ERROR on unknown/NULL input instead of silently returning SSH_DIGEST_AUTO
- Use strlen() before strcmp() to short-circuit string comparisons.

Handle GSSAPI "null" hostkey case in wrapper.c.
Add unit tests for the new function.

Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/355
Signed-off-by: Haythem666 <haythem.farhat@epfl.ch>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-24 10:50:39 +01:00
Manas Trivedi
9f7c596ca5 tests: add coverage for NULL session in ssh_channel_is_open
Signed-off-by: Manas Trivedi <manas.trivedi.020@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-24 10:15:06 +01:00
Jakub Jelen
f060583d6f tests: Generate coverage for fuzzing tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
2026-03-19 22:16:17 +01:00
Bulitha Kawushika De Zoysa
a05b2b76be tests: initialize sftp test pointers to NULL
Signed-off-by: Bulitha Kawushika De Zoysa <bulithakaushika99@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-19 17:06:05 +01:00
Bulitha Kawushika De Zoysa
c9f34ac55f sftp: Add support for the users-groups-by-id@openssh.com OpenSSH extension on the server side.
Signed-off-by: Bulitha Kawushika De Zoysa <bulithakaushika99@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-19 17:06:04 +01:00
Ahmed hossam
bc24bba176 docs: Add documentation for test_server functions
Signed-off-by: Ahmed hossam <ahmed.hossambahig@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2026-03-19 17:03:42 +01:00
Shreyas Mahajan
e927820082 Make headers self-contained and include-order independent
Signed-off-by: Shreyas Mahajan <shreyasmahajan05@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
2026-03-16 19:07:16 +01:00
Jakub Jelen
31ea4d1213 tests: Negative tests for ssh_pki_ctx_options_set
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
2026-03-16 19:04:57 +01:00