作者:Carre陈 | 来源:互联网 | 2023-05-19 06:30
我想了解Ssh.NET如何成功建立连接:SshClientclientnewSshClient(127.0.0.1,22,root,);client.Connect()
我想了解Ssh.NET如何成功建立连接:
SshClient client = new SshClient("127.0.0.1", 22, "root", "");
client.Connect();
// Connection ok? Then continue, else display error
SshCommand x = client.RunCommand("service apache2 status");
client.Disconnect();
client.Dispose();
我如何证明“client.RunCommand(”service apache2 status“)的结果;”逻辑?
例如. if(x ==“apache2正在运行”)
解决方法:
您可以查看SshClient.IsConnected
酒店:
if (!client.IsConnected)
{
// Display error
}