Send commands to SSH session in PowerShell and receive output in TextBox Send commands to SSH session in PowerShell and receive output in TextBox powershell powershell

Send commands to SSH session in PowerShell and receive output in TextBox


You are obviously connecting to some "device", not a full server. Embedded SSH implementations usually do not implement SSH "exec" channel. You have to use "shell" channel (what is otherwise not recommended for command automation).

With Plink you can achieve that by writing the "command" to Plink input, instead of using the -m switch.

See also Executing command using Plink does not work, but does in PuTTY.


Though you should not run an external application to implement SSH. Use a native .NET SSH implementation, like SSH.NET. Pseudo code to execute command with SSH.NET in "shell" channel:

var client = new SshClient(...);client.Connect();var shell = client.CreateShellStream(...);shell.WriteLine("command");var output = shell.Read();

The "shell" channel is a black box with an input and an output. There is no reliable way to use it to execute a command, read its output, and execute other commands. You have no API to tell when a command execution has ended. That is why I wrote above that the "shell" channel is not recommended for command automation. All you can do is to parse the shell output and look for your device's command prompt: System_20>.