Skip to content

Support writing to stdin when executing a remote command #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hifi opened this issue Sep 11, 2016 · 3 comments
Closed

Support writing to stdin when executing a remote command #85

hifi opened this issue Sep 11, 2016 · 3 comments

Comments

@hifi
Copy link
Contributor

hifi commented Sep 11, 2016

SSH.NET currently does not support executing a command (without shell) with an option to directly write to the stdin of the executed program. A writable stream is needed for that.

This is a critical feature when you need to pipe large amounts of data from SSH.NET to remote commands.

@hifi
Copy link
Contributor Author

hifi commented Sep 12, 2016

So it was rather easy to implement but here's the minimum amount of changes required to get writing working:

https://gist.github.com/hifi/d7c4e3689e28df13893fc0c4fd813706

Ideally it should use something like PipeStream to expose a InputStream for writing instead of raw byte arrays. Also it's worth noting that SendEof must be called to close stdin. Failing to do that, a program you are executing could end up waiting input forever. Closing this InputStream should do this implicitly so you can signal the program on the other send that you are finished.

@Livius90
Copy link

Livius90 commented Sep 4, 2022

Is this feature available now? I would like to send diskimage datas from C# to a stdin pipe of dd over SSH, like in this example.

Is that pipe data sending Linux style is available to use in SSH.NET?

# dd bs=16M if=/dev/sda | ssh root@serverB "dd bs=16M of=/dev/sda"

@Rob-Hague
Copy link
Collaborator

This was added in version 2024.0.0 in #1293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants