0 votes
by (350 points)

I am using the SSHChannel and need to read and process any data I receive on that channel.
In the help I found the SshChannel.Receive method and that works but not sure how to keep reading from the channel.
Is there a event or Task or Async method I can use?
At present all I know to do is to make a thread and keep doing SshChannel.Receive but this seems cumbersome.

( I do not typically code in .Net so I do not know it well)


1 Answer

+1 vote
by (3.9k points)
selected by
Best answer

Actually, the SshChannel class is very low API. For common cases you don't need to use it.

If you want to use SSH protocol for file transfers, use rather Sftp class or Scp class.
If you want to script a shell, use rather Scripting class.

If for some reason you really want to use low level SshChannel class then call Receive in a loop as you have written.