I\'m using C# with SSH.NET and have been able to get a client SSH connection working fine to executing commands across SSH. I can connect to a Linux install I have on a hyp
You can implement a shell session using:
SshClient.CreateShellStream
(ShellStream
class) — It gives you one Stream
interface, that you can both write and read. This interface is useful, when you want to interact with the shell directly.SshClient.CreateShell
(Shell
class) — Where you yourself provide separate streams for input, output and error output. This interface is useful, when you want to link/pipe the input and output to existing streams (like standard input and output or files). Though you can still interact directly, if you use PipeStream
. See also SSH.NET doesn't process my shell input commands.But using "shell" is really not recommended for automating commands execution. A shell is an interactive feature, that does not have a deterministic behavior.
You better use an exec channel, see How to run commands on SSH server in C#?
For the record, this was resolved by using SSH to connect and open a tunnel, then using telnet to do the interactive part. SSH.NET was not mature enough on the interactive side.