string host="10.26.158.117",user="test",pwd="Test123$";
using (var client = new SshClient(host, user, pwd))
{
client.Connect(); //這里就報錯,錯誤提示是 An established connection was aborted by the software in host machine.
var output = client.RunCommand("echo test");
client.Disconnect();
Console.WriteLine(output.ToString());
}
uj5u.com熱心網友回復:
代碼不全,SshClient 連接時沒有看到埠號,你連接到 10.26.158.117 的哪個埠?ssh默認是22。另外使用其他 ssh 工具能連接 10.26.158.117 嗎?
uj5u.com熱心網友回復:
默認埠是22可以不用寫,在win7下用open-ssh可以登錄,用C#就不行,提示對方主機拒絕。
uj5u.com熱心網友回復:
我當時也用的Renci.SshNet
我是連接sftp時,用到的。
你看一下有什么區別吧。
https://blog.csdn.net/hanjun0612/article/details/78246844
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/90697.html
標籤:C#
下一篇:DotNetBar點擊切換頁面
