通过SSH从c#执行linux命令mkdir

时间:2019-01-30 15:25:18

标签: c# linux ssh

我尝试了以下代码,使用ssh从c#在Linux的Download文件夹下创建测试目录。

SshClient sshclient;

using (sshclient = new SshClient("192.168.0.15", 22, "oracle", "oracle"))
{
     sshclient.KeepAliveInterval = new TimeSpan(0, 1, 40);
     sshclient.ConnectionInfo.Timeout = new TimeSpan(0,1, 20);
     sshclient.Connect();
     SshCommand x;
     x = sshclient.RunCommand("mkdir -p /home/oracle/Downloads/test");
     x.Execute();
     string answer = x.Result;
}

上面的代码没有给出任何异常,但是我已经使用调试器附加了堆栈跟踪

Stack Trace

0 个答案:

没有答案