Hi,
There are two ways to do this
Another Ssh is a long and interactive command.
There are two ways to do this
-
ShellStream and Async write/read (quite difficult)
-
Use PortForwarding
In your case you want the ssh port (22) of the machine 192.168.1.11
using (var client = new SshClient("192.168.1.10", "root", "magic!0n3"))
{
client.Connect();
// foward remote ssh port to your local machine
ForwardedPortLocal forwarding = new ForwardedPortLocal("127.0.0.1", "12345", "192.168.1.11", "22");
client.AddForwardedPort(forwarding);
forwarding.Start();
// connect to it
SshClient forwardedSsh = new SshClient("127.0.0.1", 12345, "root", "password/key");
forwardedSsh.Connect();
// run your commands
MessageBox.Show(forwardedSsh.RunCommand("ls").Result);
}
RunCommand() is for short and non-interactive commands.Another Ssh is a long and interactive command.