I'm connecting to a linux server from my .net application using SSH.NET. Each command that I execute completes as expected with the exception of pbrun su - myaccount.
While debugging, when the pbrun su - myaccount command is executed, the arrow in the debugger disappears and control is never returned to visual studio, thus requiring me to manually stop debugging the application.
If the problem is that pbrun is asking for something in stdin (password, reason, etc) you can create a shell with streams controled by you and write in it.
Simple example:
using System;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var connectionInfo = new Renci.SshNet.PasswordConnectionInfo("ancardia.us.to", "adom", "adom");
var ssh = new Renci.SshNet.SshClient(connectionInfo);
ssh.Connect();
var shell = ssh.CreateShell(Console.OpenStandardInput(), Console.OpenStandardOutput(), Console.OpenStandardOutput());
shell.Start();
while (true) {
Console.Read();
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With