tmds / Tmds.Ssh

.NET SSH client library
MIT License
177 stars 10 forks source link

Support custom subsystem with ExecuteAsync #182

Closed jborean93 closed 4 months ago

jborean93 commented 4 months ago

It would be great if ExecuteAsync (or some variant) had a way to specify using a custom subsystem rather than a command. For example the OpenSSH cli can open a connection to a subsystem with ssh -s user@remote subsystem_name.

As some background PowerShell Remoting is done through a custom subsystem configuration https://learn.microsoft.com/en-us/powershell/scripting/security/remoting/ssh-remoting-in-powershell?view=powershell-7.4. The SSH service registers a subsystem (typically called powershell) that is set to run a set executable with an argument.

Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -nologo

The PowerShell client internally runs uses ssh -s user@remote powershell to open the connection and exchange the PSRemoting packets over stdin/stdout of this new connection. I'm hoping to use this library to achieve the same thing instead of relying on the ssh binary.

tmds commented 4 months ago

Thanks for creating the issue, and elaborating on the use-case!

What do you think about this API:

Task<RemoteProcess> ExecuteSubystemAsync(string subsystem CancellationToken cancellationToken);
Task<RemoteProcess> ExecuteSubystemAsync(string subsystem, ExecuteOptions? options = null, CancellationToken cancellationToken = default);
jborean93 commented 4 months ago

You read my mind as I was working on https://github.com/tmds/Tmds.Ssh/pull/183 which used that exact name!