Commit Graph

1696 Commits

Author SHA1 Message Date
dependabot[bot] cd3160add9 Bump actions/upload-pages-artifact from 4.0.0 to 5.0.0 (#1789)
Bumps [actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact) from 4.0.0 to 5.0.0.
- [Release notes](https://github.com/actions/upload-pages-artifact/releases)
- [Commits](https://github.com/actions/upload-pages-artifact/compare/7b1f4a764d45c48632c6b24a0339c27f5614fb0b...fc324d3547104276b827a68afc52ff2a11cc49c9)

---
updated-dependencies:
- dependency-name: actions/upload-pages-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-26 12:58:01 +02:00
dependabot[bot] 24c4aa416a Bump NuGet/login from 1.1.0 to 1.2.0 (#1790)
Bumps [NuGet/login](https://github.com/nuget/login) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/nuget/login/releases)
- [Commits](https://github.com/nuget/login/compare/d22cc5f58ff5b88bf9bd452535b4335137e24544...8d196754b4036150537f80ac539e15c2f1028841)

---
updated-dependencies:
- dependency-name: NuGet/login
  dependency-version: 1.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-26 12:57:34 +02:00
dependabot[bot] 2b01ff3558 Bump actions/setup-dotnet from 5.2.0 to 5.3.0 (#1802)
Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 5.2.0 to 5.3.0.
- [Release notes](https://github.com/actions/setup-dotnet/releases)
- [Commits](https://github.com/actions/setup-dotnet/compare/c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7...9a946fdbd5fb07b82b2f5a4466058b876ab72bb2)

---
updated-dependencies:
- dependency-name: actions/setup-dotnet
  dependency-version: 5.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-26 12:43:46 +02:00
dependabot[bot] 855c3e29ae Bump alpine from 3.23 to 3.24 in /test/Renci.SshNet.IntegrationTests (#1806)
Bumps alpine from 3.23 to 3.24.

---
updated-dependencies:
- dependency-name: alpine
  dependency-version: '3.24'
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-26 12:42:43 +02:00
Rob Hague 5b8382de26 Serialise packets into a buffer (#1792)
A byte array is allocated to hold each plaintext packet. This removes that by adding
a buffer for that purpose.
2026-05-05 13:41:35 +02:00
Rob Hague b6217cb763 Remove plaintext receive buffer (#1788)
#1752 added a persistent buffer into which to decrypt packets, rather than allocating
a new array for each packet. This was on the back of #1733 which added support in the
cipher types for decrypting into a given buffer, but for the case of AES-CTR, not into
the same buffer in-place. #1787 adds that missing support, meaning we can now decrypt
in-place, and the plaintext buffer becomes unnecessary.
2026-05-05 12:59:01 +02:00
Rob Hague 8ed8d38fa8 Encrypt packets in-place (#1787)
Support in-place encryption in the cipher types, then use it on the plaintext packets
instead of allocating a new array each time. Removes 2 of 4 bytes allocated for each
byte uploaded over SFTP.

For AES-CTR, supporting in-place encryption in this case means adding a persistent buffer
for the keystream and encrypting in chunks. The performance difference is ~1-2% i.e.
marginal versus one-shotting it. The variance is similar also for different choices of
buffer size (here 4096 is used).
2026-05-05 12:57:13 +02:00
Rob Hague 45d8631266 Add SECURITY.md (#1785)
Point to GH private vulnerability reporting
2026-04-12 18:15:31 +02:00
Rob Hague 04a6dc04c2 Harden actions (#1784)
* Harden actions

- Pin remaining actions
- Specify top-level/default `permissions: contents: read` in build.yml
- Set `persist-credentials: false` on checkout
- Add an environment for nuget publish job and use `release` event trigger
- Add dependabot cooldown

* Update .github/workflows/build.yml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-12 18:15:16 +02:00
mus65 25a931cafe ScpClient: allow disabling the -d flag (#1751)
* ScpClient: allow disabling the -d flag

fixes #1746

* Apply suggestion from @Rob-Hague

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2026-03-22 10:26:37 +01:00
mus65 0ff2c50765 SftpClient: add IProgress to DownloadFileAsync and UploadFileAsync (#1771)
* SftpClient: add DownloadFileAsync overload with downloadCallback

fixes #1765

* Change to IProgress and also add to UploadFileAsync
2026-03-16 19:47:59 +01:00
mus65 8cd6ad65b1 fix Build with newer .NET 10 SDKs (#1772)
* fix Build with newer .NET 10 SDKs

The IDE0370 are a mess since they only affect certain target frameworks.
Maybe we should disable this one completely instead?

Also set a fixed SDK Version in CI so this doesn't randomly break again.

* Remove IDE0370

* global.json: use latestMinor

to make sure that dotnet-setup installs the
exact version, see https://github.com/sshnet/SSH.NET/pull/1772#discussion_r2941495945

* Update global.json

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2026-03-16 19:31:32 +01:00
Copilot c3da85d011 Add GitHub Copilot instructions for SSH.NET (#1767)
* Initial plan

* Add GitHub Copilot instructions for SSH.NET

Co-authored-by: WojciechNagorski <17333903+WojciechNagorski@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: WojciechNagorski <17333903+WojciechNagorski@users.noreply.github.com>
2026-03-16 11:06:15 +01:00
dependabot[bot] 4a6f7fd5fe Bump the dependencies group (#1761)
* Bump the dependencies group

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2026-03-02 20:53:52 +01:00
Copilot 41dde35d74 Replace custom TestMethodForPlatformAttribute with MSTest OSCondition (#1766)
* Initial plan

* Replace TestMethodForPlatformAttribute with OSCondition attribute

Co-authored-by: Rob-Hague <5132141+Rob-Hague@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Rob-Hague <5132141+Rob-Hague@users.noreply.github.com>
2026-03-01 18:02:08 +01:00
Rob Hague 085dead8f5 Add a plaintext receive buffer (#1752)
Continuing from previous changes, add a persistent buffer into which the message
payload is decrypted, rather than allocating a new array each time.
2026-02-10 19:47:43 +01:00
dependabot[bot] 1a977495a5 Bump actions/upload-artifact from 5 to 6 (#1757)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-08 16:59:02 +01:00
dependabot[bot] dc9082d9e2 Bump actions/download-artifact from 6 to 7 (#1756)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-08 16:58:33 +01:00
dependabot[bot] 6b19cbfcb1 Bump alpine from 3.22 to 3.23 in /test/Renci.SshNet.IntegrationTests (#1755)
Bumps alpine from 3.22 to 3.23.

---
updated-dependencies:
- dependency-name: alpine
  dependency-version: '3.23'
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-08 16:57:44 +01:00
dependabot[bot] 89ea230750 Bump the dependencies group with 6 updates (#1743)
* Bump the dependencies group with 6 updates

Bumps BenchmarkDotNet from 0.15.3 to 0.15.8
Bumps GitHubActionsTestLogger from 2.4.1 to 3.0.1
Bumps Meziantou.Analyzer from 2.0.220 to 2.0.257
Bumps Nerdbank.GitVersioning from 3.7.115 to 3.9.50
Bumps SonarAnalyzer.CSharp from 10.15.0.120848 to 10.16.0.128591
Bumps Testcontainers from 4.7.0 to 4.9.0

---
updated-dependencies:
- dependency-name: BenchmarkDotNet
  dependency-version: 0.15.8
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
- dependency-name: GitHubActionsTestLogger
  dependency-version: 3.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: dependencies
- dependency-name: Meziantou.Analyzer
  dependency-version: 2.0.257
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: dependencies
- dependency-name: Nerdbank.GitVersioning
  dependency-version: 3.9.50
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: SonarAnalyzer.CSharp
  dependency-version: 10.16.0.128591
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
- dependency-name: Testcontainers
  dependency-version: 4.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>

* TimeSpan.Zero

* bump

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
2025-12-23 11:22:32 +00:00
mus65 adbb68e6e8 Add UploadFileAsync override with canOverride (#1750)
fixes #1734
2025-12-23 11:04:27 +00:00
dependabot[bot] 4648e0a614 Bump actions/checkout from 5 to 6 (#1744)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-23 10:30:22 +00:00
mus65 e1520eda21 Migrate solution to slnx format (#1749)
see https://devblogs.microsoft.com/dotnet/introducing-slnx-support-dotnet-cli/
2025-12-23 10:29:37 +00:00
Rob Hague 8712c99377 Add a socket receive buffer (#1733)
Currently an array is allocated to read each packet from the socket, followed by
decryption which allocates another array for the plaintext payload. We can save one
of these two allocations by adding a persistent buffer for socket receives, and
allowing the cipher implementations to decrypt into the given payload array.

We can save the other allocation similarly, but in a separate change.
2025-11-21 21:21:25 +01:00
Rob Hague cbbbddecf9 Write into the underlying buffer in SshDataStream (#1739)
Several commonly used Write methods on SshDataStream end up calling Write(ReadOnlySpan)
on the base MemoryStream. But since SshDataStream is a derived type, that method just
rents a buffer and hands it to Write(byte[], int, int), which defeats any stackalloc'ing
or renting that SshDataStream does itself. Instead, with a bit extra accounting we can
just write directly into the underlying buffer.
2025-11-21 20:13:33 +01:00
Rob Hague bafd867c12 Rent buffers used in SFTP reads (#1738)
An SFTP download performs several reads from the server in parallel, allocating an array
to store each result until it's ready to be consumed. Since these buffers are short-lived
and normally of the same large-ish size (32KB), it seems like a good candidate for pooling.
2025-11-21 19:54:25 +01:00
Rob Hague 330e9331e9 Truncate local file in ScpClient.Download (#1729)
Similar to #1686 but for the local side of SCP: opening the file should use
Create not OpenWrite.

closes #648
2025-11-21 19:53:44 +01:00
Rob Hague 391065830a Enable nullable in ConnectionInfo (#1728) 2025-11-21 19:53:29 +01:00
mus65 4e02502bdf Add .NET 10 target and make use of C#14 extension members (#1672)
* Add .NET 10 target

* fix IDE0031

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0031

* fix ca5399

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca5399

* fix ca1515

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1515

* fix ca2002

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2002

* fix ca1508

new false positives.

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1508

* fix ca2000

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2000

* fix ca2025

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2025

* fix ca1849

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1849

* fix Reverse() overloads

because of https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/10.0/csharp-overload-resolution

* supress CA2002

* Use extension members for ThrowHelpers

* use extension members for CryptoAbstractions

* use extension member for DateTime.UnixEpoch

* use extension members for string.Join etc

* use extension members for Convert.To/FromHexString

* disable CA1508

* Update .NET 10 RC2

* Workaround Build Regression in .NET 10 RC2

https://github.com/dotnet/sdk/issues/51265

* suppress new warnings introduced by merge

* Update to .NET 10 final release

* Revert "Workaround Build Regression in .NET 10 RC2"

This is fixed in the final release.

This reverts commit 5a59ac9aa8.

* fix new warnings with MSTest 4 + .NET 10

* use same Randomizer instance

* disable CA2000

* reduce CA1849 suppressions

and disable duplicate S6966

* disable preview analyzers

reverts 6c3c06d95a
2025-11-15 12:21:49 +01:00
mus65 933613e31c Update to MSTest 4 (#1721)
* Update to MSTest 4

* fix TestMethodForPlatformAttribute

replace Execute with ExecuteAsync and fix MSTEST0057

https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0057 (link currently dead)

* fix compilation error

* fix MSTEST0037

https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0037

* fix MSTEST0052

https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0052

* fix MSTEST0045

Fixing this properly would require the tests to respect
testContext.CancellationToken. I'm not sure this is worth fixing
or how to even do it for the sync methods.

https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0045

* fix MSTEST0001

I assume that parallelization would break a lot of stuff.

https://learn.microsoft.com/en-us/dotnet/core/testing/mstest-analyzers/mstest0001

* Workaround for new Sonar warnings because of MSTest4

* revert analyzer fixes in OrderedDictionaryTest

* use custom sync console logger for MSTest

to work around https://github.com/microsoft/testfx/issues/6457

* remove redundant args

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-11-14 22:09:13 +01:00
Scott Xu bf976d595a Use native AesGcm for .NET Framework from nuget (#1619)
* Use native AesGcm for .NET Framework from nuget

* drop mono exception

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-11-14 21:41:31 +01:00
dependabot[bot] 8629c39760 Bump actions/download-artifact from 5 to 6 (#1726)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-13 21:02:23 +01:00
dependabot[bot] 7ba28f0f4d Bump actions/upload-artifact from 4 to 5 (#1727)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-13 21:01:28 +01:00
Rob Hague e5ad82c8c6 Set version to 2025.1.1-prerelease.{height} (#1723) 2025-10-27 21:43:43 +01:00
Rob Hague 6390ede31e Set version to 2025.1.0 stable (#1722) 2025.1.0 2025-10-27 21:36:23 +01:00
mus65 b3cfe5aa14 Automatically publish tags to NuGet with Trusted Publishing (#1715) 2025-10-27 19:54:23 +01:00
Copilot 821f958a22 Fix typos in comments: "lenght" → "length" and "occured" → "occurred" (#1719)
* Initial plan

* Fix comment typos: lenght→length, occured→occurred

Co-authored-by: WojciechNagorski <17333903+WojciechNagorski@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: WojciechNagorski <17333903+WojciechNagorski@users.noreply.github.com>
2025-10-23 13:06:31 +02:00
Rob Hague 58f61a2398 Override WriteAsync in ShellStream (#1711)
ShellStream does not currently override the Read/Write async variants. They fall back to
the base class implementations which run the sync variants on a thread pool thread, only
allowing one call of either at a time in order to protect implementations that would
break if Read/Write were called simultaneously. In ShellStream, reads and writes are
independent so mutually excluding their use is unnecessary and can lead to effective
deadlocks.

We therefore override WriteAsync to get around this restriction. We do not override
ReadAsync because the sync implementation does not lend itself well to async given the
use of Monitor.Wait/Pulse. Note that while reading and writing simultaneously is allowed,
it is not intended that ShellStream is used with multiple simultaneous reads or multiple
simultaneous writes, so it is fine to keep the base one-at-a-time implementation on
ReadAsync.

Another note is that the new WriteAsync will be simple (synchronous) buffer copying in
most cases, with a call to FlushAsync in others. We also do not override FlushAsync, so
that will go onto a thread pool thread and potentially acquire some locks. But given that
the current base implementation of WriteAsync does that unconditionally, it makes the new
WriteAsync slightly better and certainly no worse than the current version.
2025-10-23 09:13:26 +02:00
Rob Hague cb1f26d21d Internal cleanup in SftpSession (#1717)
Delete some Begin/End methods, use <inheritdoc/>
2025-10-23 08:46:39 +02:00
Rob Hague cd9ec8f395 Add SftpException and SftpPathNotFoundException.Path (#1716)
This adds an SftpException which sits between the existing SftpPathNotFoundException/
SftpPermissionDeniedException and SshException, and which contains the response code
from the SSH_FXP_STATUS packet, along with a default message if one was not provided.

SftpPathNotFoundException also gains a Path property which is populated in cases where
it makes sense.
2025-10-23 07:34:26 +02:00
Rob Hague dccdedc36e Build the read-ahead mechanism into SftpFileStream (#1705)
* Build the read-ahead mechanism into SftpFileStream

This change unifies the SFTP download implementations that exist via DownloadFile and
via SftpFileStream, by rewriting SftpFileStream to perform the same "read-aheads" as
DownloadFile. This brings the performance of downloads via SftpFileStream in line with
DownloadFile, such that the latter is now effectively SftpFileStream.CopyTo. It also
brings the recently added DownloadFileAsync up to speed since that was implemented via
SftpFileStream.CopyToAsync.

The methodology is a mix of the previous one and that within OpenSSH: the first call to
SftpFileStream.Read sends one read request to the server. The second sends two and when
not interrupted by Write or similar, the number of in-flight read requests continues to
scale up in this fashion.

I have measured CopyTo to be 3-20x faster than before, depending on file size and server
round-trip time.

* Check CanSeek in ReadAllBytes

* Squeeze out some performance
2025-10-22 19:55:13 +02:00
Nikola Milekic c5c6f28d60 Avoid rounding issues when checking Timeout values (#1700) (#1712)
* Avoid rounding issues when checking Timeout values (#1700)

AsTimeout is called from the SshCommand constructor with
Timeout.InfiniteTimeSpan. In this scenario the range check should never
fail, but unfortunately it does in certain scenarios, due to a runtime
or compiler bug (as soon as optimizations are turned off the issue
miraculously disappears).

Closes #1700

* fix tests

---------

Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
2025-10-08 10:43:13 +02:00
mus65 ebdcb3ea7d CI: add Windows Integration Tests for .NET (#1704)
* CI: add Windows Integration Tests for .NET

see https://github.com/sshnet/SSH.NET/pull/1702#issuecomment-3342506642

* fix podman setup with Windows and .NET

* debug

* x

* x

* x

* revert

* Run Windows .NET tests in separate job

so they run in parallel and we avoid the Common_CreateMoreChannelsThanMaxSessions test failure.

* fix coverlet artifacts

* fix missing PermitTTY in RemoteSshdConfig Reset

this fixes a test failure in Common_CreateMoreChannelsThanMaxSessions
when running the tests multiple times against the same SSH server
instance.

see https://github.com/sshnet/SSH.NET/pull/1704#issuecomment-3343210311

* speed up Windows tests

turns out this is caused by DNS resolution taking about
2 seconds on every new connection...

* add windows integration tests to Publish needs:

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
2025-10-04 10:00:09 +01:00
Rob Hague af279d206a Fix SftpFileAttributes file type detection (#1688)
* Fix SftpFileAttributes file type detection

To get the file type, S_IFMT should be used as the mask. Instead it was using each file
type as the mask. It meant that e.g. a symbolic link would also show as a regular file
and a character device.

Also allow setting and retrieving the setuid/setgid/sticky bits

* fix build
2025-10-01 22:19:42 +02:00
Rob Hague c335ce2f20 Remove calls to Socket.Poll and use SocketShutdown.Both (#1706)
The message loop currently sits in a call to Poll until the socket has data to read or
it is closed. This is unnecessary - it can equally just sit in the call to Receive.

The call to Poll in Session.IsConnected is also unnecessary - we can instead just call
Socket.Connected. This only returns the connection state as of the last operation, but
we are always performing operations in the message loop (or else we are not connected),
so it should work equally well while being cheaper.

Lastly, when shutting down the socket, shut down both sides rather than just the sending
side (SocketShutdown.Both rather than SocketShutdown.Send) - at this point we do not care
about reading anything else. This makes it (more) certain that we will break out of the
Receive call in the message loop, as has been noted in #355 for whatever remaining issues
still exist there.
2025-10-01 20:19:28 +02:00
Scott Xu 081d3052b4 Use BCL Curve25519 for Windows 10+ (#1702)
* Use BCL Curve25519 when possible

* Update KeyExchangeMLKem768X25519Sha256 and KeyExchangeSNtruP761X25519Sha512

* Split Start and Finish methods for inheritance

* Some refactor

* Update src/Renci.SshNet/Security/KeyExchangeEC.BclImpl.cs

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* revert

* Create dedicated KeyExchangeECCurve25519 BclImpl

* cleanup

* minor code refactor

* integration test

* Revert "integration test"

This reverts commit 326962664c.

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-10-01 20:18:29 +02:00
dependabot[bot] 2f0ae3190c Bump test dependencies (#1693)
* Bump actions/checkout from 4 to 5
* Bump actions/upload-pages-artifact from 3 to 4
* Bump actions/download-artifact from 4 to 5
* Bump the dependencies group with 5 updates
* fix
* fix locally failing portforwarding tests

port already in use

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-09-22 22:42:30 +02:00
Rob Hague b199467971 Fix key material extension during key exchange (#1689)
When the key exchange produces less key material than is needed for the cipher or hmac
algorithms, there is an iterative procedure to produce more.

For example, a SHA-1 key exchange algorithm produces 20 bytes of key material.
A SHA-256 hmac uses a 32 byte key, so one iteration of the procedure produces another
20 bytes of key material for a total of 40 which is sufficient for the hmac key.

The library works correctly in such cases of one iteration, but the logic is wrong if
more than one iteration is needed. In #1660, the connection uses a SHA-1 kex algorithm
with a SHA-512 hmac (64 byte key), requiring 3 iterations of the extension procedure and
resulting in an error upon connection.

This change fixes the logic to use the output of the previous iteration per the spec.

closes #1660
2025-08-17 23:49:40 +02:00
Rob Hague 6cba1be72e Truncate existing file in CreateText (#1686)
SftpClient.CreateText does not truncate the file if it exists, contrary to
System.IO.File.CreateText which does. It is documented, but seems pretty
unintuitive and more like a mistake than a concious decision.

I considered leaving this 14 year old behaviour as it is, but turns out other
people have hit it as well (it also affects WriteAll{Bytes/Text/Lines}).
2025-08-10 17:11:42 +02:00
dependabot[bot] 03ae6bfa0f Bump dependencies (#1682)
* Bump the dependencies group with 4 updates

Bumps BouncyCastle.Cryptography from 2.6.1 to 2.6.2
Bumps Meziantou.Analyzer from 2.0.205 to 2.0.210
Bumps MSTest from 3.9.3 to 3.10.0
Bumps SonarAnalyzer.CSharp from 10.13.0.120203 to 10.15.0.120848

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-08-02 17:57:09 +02:00