sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.96k stars 931 forks source link

Added SshCommand.InputStream to allow writing to stdin of SshCommand #1293

Closed realvizu closed 7 months ago

realvizu commented 8 months ago

Changes:

I you have recommendations for further unit tests, please advise.


I started the work by trying to run all unit tests on my dev machine to see if they all pass. Unfortunately a lot of them failed, so I had to make the following modifications (see the changes in my first commit in this PR):

If you know a better fix for any of the above modifications, please advise.

WojciechNagorski commented 8 months ago

It looks good to me! But I need more time to test it!

Do you have a specific function in mind that you want to implement using this functionality? Did you see that it can be useful in https://github.com/dotnet/Docker.DotNet/issues/540

WojciechNagorski commented 8 months ago

image Those tests work on my machine.

realvizu commented 8 months ago

It looks good to me! But I need more time to test it!

Do you have a specific function in mind that you want to implement using this functionality? Did you see that it can be useful in dotnet/Docker.DotNet#540

I had a very specific use case: I had to call some legacy system that is implemented as a set of SSH commands and one of the commands requires sending a file via input stream. These changes made it work.

realvizu commented 8 months ago

Thanks a lot @WojciechNagorski and @Rob-Hague for the comments and suggestions!

realvizu commented 7 months ago

Shall I do a squash+rebase onto develop before merging the PR?

Rob-Hague commented 7 months ago

It will be merged with "Squash and merge" so it is not necessary

(it requires a CODEOWNERS approval before it can merge)

WojciechNagorski commented 7 months ago

There is a build problem:

C:\projects\ssh-net\test\Renci.SshNet.IntegrationTests\SshClientTests.cs(37,33): error CS7036: There is no argument given that corresponds to the required parameter 'offset' of 'Stream.Write(byte[], int, int)' [C:\projects\ssh-net\test\Renci.SshNet.IntegrationTests\Renci.SshNet.IntegrationTests.csproj::TargetFramework=net48]

WojciechNagorski commented 7 months ago

This issue has been fixed in the 2024.0.0 version.