Commit Graph

1672 Commits

Author SHA1 Message Date
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
Rob Hague 605ee7fe23 Use ReadExactly in ReadAllBytes and yield in ReadLines (#1681)
* Use ReadExactly in ReadAllBytes and yield in ReadLines

* on second thought, open the file lazily in ReadLines
2025-08-02 16:32:08 +02:00
dependabot[bot] 9f733e4393 Bump Vampire/setup-wsl from 5.0.1 to 6.0.0 (#1683)
Bumps [Vampire/setup-wsl](https://github.com/vampire/setup-wsl) from 5.0.1 to 6.0.0.
- [Release notes](https://github.com/vampire/setup-wsl/releases)
- [Commits](https://github.com/vampire/setup-wsl/compare/3b46b44374d5d0ae94654c45d114a3ed7a0e07a8...6a8db447be7ed35f2f499c02c6e60ff77ef11278)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-02 13:01:42 +02:00
Rob Hague 13bcb7713e Remove unnecessary SftpFileStream unit tests and dedup Open{Async} (#1680)
* deletions

* test additions/tweaks

* dedup SftpFileStream init logic
2025-08-02 12:15:14 +02:00
Rob Hague dab8a11738 Use BouncyCastle for Diffie-Hellman key exchange (#1654)
Removes another vestige of hand-rolled crypto, and makes the classes public +
configurable for if/when we remove certain algorithms.
2025-08-02 11:08:56 +02:00
Rob Hague b7c5f1a87d Adapt InternalUploadFile for async (#1653)
The recently added UploadFileAsync effectively calls stream.CopyToAsync(SftpFileStream).
This is slower than the sync UploadFile (by about 4x in a local test) because the sync
version sends multiple write requests concurrently, without waiting for each response
in turn like the stream-based version does.

This change adapts the sync code for async and uses it to bring the performance of
UploadFileAsync in line with that of UploadFile.
2025-08-02 11:08:27 +02:00
Bart Vries d40bc43ac1 Refactor logging to allow a loggerfactory per session (#1673)
* Refactor logging to allow a loggerfactory per session specified in the ConnectionInfo.

This commit introduces an `ILoggerFactory` to various classes, replacing the static logger factory with an instance-based approach for more flexible and session-specific logging. These changes improve the logging framework's flexibility and maintainability and allow unit testing of logging.

* Improvements bases on feedback. Fixed tests. Added documentation.

* Update src/Renci.SshNet/ConnectionInfo.cs

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-07-26 21:24:48 +02:00
dependabot[bot] fc988bd938 Bump dependencies
* Bump the dependencies group with 5 updates

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

* seal types not publicly instantiable (ma0053)

---------

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-07-12 21:03:08 +02:00
Jacob Slusser 4886529ee2 Fixes spelling errors (#1668)
* Fixes spelling errors in comments, private members, and public members in test projects

* Adds en-GB as spell checker option; reverts notable cases of American English

* convert file UTF-16 LE BOM -> UTF-8

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-07-12 21:01:57 +02:00
thegame4craft 6bb397872b scp: notify for uploading finished when uploaded an empty file (#1658)
* scp: add flag to notify for uploading finished when uploaded an empty file

* remove notifyOnEmptyFile Flag
2025-06-20 08:53:51 +02:00
Rob Hague fd05d76ad6 Use ArraySegment for channel data (#1650)
The library currently allocates 4 bytes (and some) for every 1 byte of file
downloaded(*). It could be 0. This takes it to 3.

(*)
1. Array allocated for read of encrypted packet from socket
2. Array for decrypted packet
3. Array for channel data (removed in this change)
4. Array for sftp data packet
2025-06-06 08:52:23 +02:00
Rob Hague 1f1a5fe2ac Use an array buffer for the sftp packet stream (#1649)
The sftp packet stream runs within but independently of the channel data stream,
meaning a channel data packet can contain multiple sftp packets, or an sftp packet
can be split across multiple channel data packets.

Normally the packets are sized such there is a 1-to-1 relationship for efficiency.
When this doesn't happen the library falls back to buffering via a List<byte>,
which is not so efficient. This change uses an array-based buffer instead.

In a sample download which hit this fallback I see about a 20% reduction in memory
allocated.
2025-06-06 07:34:59 +02:00
Rob Hague caac95c836 Check host key algorithms before continuing key exchange (#1642)
The library currently does not check for matching host key algorithms until needed
at the end of the key exchange, in contrast to other algorithm types which are checked
beforehand. This leads to confusing or uninformative errors, normally from the server
(correctly) closing the connection.

This change moves that check alongside the rest of them, and also improves the error
messages that arise from no matching algorithms.
2025-06-06 07:34:06 +02:00
dependabot[bot] 26bc749409 Bump dependencies (#1652)
---------

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-06-06 07:32:45 +02:00
dependabot[bot] f82ebbabea Bump alpine from 3.21 to 3.22 in /test/Renci.SshNet.IntegrationTests (#1651)
Bumps alpine from 3.21 to 3.22.

---
updated-dependencies:
- dependency-name: alpine
  dependency-version: '3.22'
  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>
2025-06-05 23:20:58 +02:00
William Decker 9cf282731a Added GetAttributesAsync to SftpClient (#1648)
* Added GetAttributesAsync to SftpClient

* Adding integration tests + unit test

* Address warnings in test classes.

---------

Co-authored-by: William Decker <william.decker@syndigo.com>
2025-06-05 23:20:13 +02:00
mus65 03e28219ba Drop netstandard2.1 target (#1647) 2025-05-29 20:33:02 +02:00
Rob Hague a024b83def Fix hang in SftpClient.UploadFile upon error (#1643)
* Fix deadlock in SftpClient.UploadFile upon error

* Make RequestWrite deterministic wrt. exception handling

* add regression test; fix race

* x
2025-05-27 09:26:36 +02:00
Ivan 4fcf6048f8 Re-introduce ChangeWindow method on ShellStream (#1646)
* Re-introduce ChangeWindow method on ShellStream

* Fix pipeline build

* Fix pipeline build

* tweaks

Co-authored-by: Glen Kleidon <glenk@galkam.com.au>
Co-authored-by: oheiheiheiheihei <294797392@qq.com>

---------

Co-authored-by: Ivan Zaitsev <crackbargains@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Co-authored-by: Glen Kleidon <glenk@galkam.com.au>
Co-authored-by: oheiheiheiheihei <294797392@qq.com>
2025-05-25 20:09:03 +02:00
mus65 f24a5d6de6 fix IDE0350 warnings with .NET SDK 9.0.300 (#1645)
test\Renci.SshNet.IntegrationTests\OldIntegrationTests\SshCommandTest.cs(460,21,460,22): warning IDE0350: Lambda expression can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0350)
2025-05-25 17:21:30 +02:00
Noah Dela Rosa d08c4aaa8a Add UploadFileAsync and DownloadFileAsync methods (#1634)
* add interface methods

* add internal file methods

* impl interface methods

* tweak buffer size usage

* swap tests with async upload

* swap more upload file references

* add async download tests

* add upload/download integration async test

* check if net48

* silence not await warning

* try tweaking test init

* remove request close from upload

* dispose already closes, remove dup call

* remove extra upload overload

* inherit doc

* configure await

* remove excess util functions

* add cancel throws

* add cancellation tests

* missed one configure await

* use default buffer size

* private ctor

* docs

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-05-05 23:03:10 +02:00
Rob Hague 7c07b10e4a Read the underlying buffer in SshDataStream (#1638)
SshDataStream is a MemoryStream, so we can access the buffer directly.
Also simplify some usage in PrivateKeyFile.
2025-05-04 12:39:01 +02:00
Rob Hague 6039e121a8 Override more methods in PipeStream, ShellStream (#1637)
Where beneficial, add additional overrides from the base Stream class. Namely the Span
variants and for PipeStream, the WriteAsync variants (see comments).

The change also adds an internal type borrowed from the runtime repo for easier buffer
management, which could also be used elsewhere.
2025-05-04 11:40:37 +02:00
Rob Hague 98982a931e Update docs and remove a leftover DSA certificate algorithm (#1632)
* Update docs and remove a leftover DSA certificate algorithm

* more cleanup
2025-05-04 11:39:54 +02:00
Rob Hague 85905082db Add a debug helper for reading traffic with Wireshark (#1627)
Wireshark can already helpfully dissect the initial SSH handshake. When given the
session keys, it can also dissect the encrypted traffic for inspection/debugging.
This adds a helper in Debug mode to write out that information in the format
Wireshark requires.

Usage is to set `SshNetLoggingConfiguration.WiresharkKeyLogFilePath` before connecting, and supply the same value to Wireshark in Edit -> Preferences -> Protocols
-> SSH -> "Key log filename".

The description of the format is at https://wiki.wireshark.org/SSH#key-log-format
2025-05-04 11:38:55 +02:00