Skip to content
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

Allow writing to SshCommand #802

Closed
blenderfreaky opened this issue Apr 8, 2021 · 1 comment
Closed

Allow writing to SshCommand #802

blenderfreaky opened this issue Apr 8, 2021 · 1 comment

Comments

@blenderfreaky
Copy link

By default you can't write to the Standard Input of a running SshCommand and can only write to a process running in SSH by using CreateShellSession. This causes a few problems in my use-case (sending protobuf-formatted packets back and forth):

  • The input is mirrored back in the output, useful in an interactive context but not for automation
  • Sending arbitrary binary data can cause problems (like accidentally sending \u001b which is escape in UTF16 or similar)
  • A newline needs to be sent in order to actually commit input to the program

I've created a workaround for this that uses evil reflection hacks for sending stuff directly to SshCommand.

Proposed changes

  • Expose IChannelSession, IChannelSession and SshCommand._channel as public

or

  • Add a public method to SshCommand that calls _channel.SendData(byte[] data, int offset, int size)

I could create a PR for either solution, although I'm not sure yet how I would write a test for this.

@Rob-Hague
Copy link
Collaborator

This was done in #1293 by way of SshCommand.CreateInputStream (https://sshnet.github.io/SSH.NET/examples.html#stream-data-to-a-command)

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

No branches or pull requests

2 participants