SSH.NET verarbeitet meine Shell -Eingabebefehle nicht
Posted: 16 Apr 2025, 07:07
Ich verwende SSH.NET, um eine Verbindung zu meinem Raspberry Pi aus einer Konsolenanwendung in C#zu verbinden. Es ist wie bei der Writeline ("LS") keinen Effekt.
Was ist das Problem?
Code: Select all
using System;
using System.IO;
using Renci.SshNet;
class Program
{
static void Main(string[] args)
{
var ssh = new SshClient("raspberrypi", 22, "pi", "raspberry");
ssh.Connect();
var input = new MemoryStream();
var streamWriter = new StreamWriter(input) { AutoFlush = true };
var stdout = Console.OpenStandardOutput();
var shell = ssh.CreateShell(input, stdout, new MemoryStream());
shell.Start();
streamWriter.WriteLine("ls");
while (true)
{
}
}
}