C#SSH.NET连接报错"value cannot be null All lists either null or empty"

来源:互联网 发布:短信免费发送软件 编辑:程序博客网 时间:2024/05/21 01:50

用网上找到的SSH.NET连接远程FTP主机,大致代码如下:

using Renci.SshNet;using Renci.SshNet.Common;Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);string user_Name = config.AppSettings.Settings["SSHUserName"].Value;string passWord = config.AppSettings.Settings["SSHpassword"].Value;string server_Ip = config.AppSettings.Settings["ftpServer"].Value;PasswordConnectionInfo sshConnectionInfo = new PasswordConnectionInfo(server_Ip, user_Name, passWord);SshClient cSSH = new SshClient(sshConnectionInfo);cSSH.Connect();SshCommand exec = cSSH.RunCommand("locate " + this.cbBoxName.Text);string All_result = exec.Result; // shell 返回结果是一个String

然后就在

cSSH.Connect();

这里报错,保存信息如下:

Value cannot be null or empty,All lists either null or emptyat Renci.SshNet.KeyboardInteractiveAuthenticationMethod.Authenticate(Session session)at Renci.SshNet.ConnectionInfo.Authenticate(Session session)at Renci.SshNet.Session.Connect()at Renci.SshNet.BaseClient.Connect()

解决方法,换上SSH.NET最新版本的dll,最新版本为2016.1.0-beta2,更新于2017年8月17日,下载链接:SSH.NET最新dll集合(2017年8月)。

阅读全文
0 0
原创粉丝点击