使用 SSH.NET 连接到 OpenSSH 7.4p1 失败并显示“服务器响应在位置处包含空字符”,但在 WinSCP

问题描述

我正在尝试使用 SSH.NET (2020.0.0) 连接到 SFTP 服务器。

我的代码看起来很简单:

try
{
    var x  = new ConnectionInfo(FtpIpAddress,22,FtpUser,new PasswordAuthenticationMethod(FtpUser,FtpPw));

    using (var sftpClient = new SftpClient(x))
    {
       sftpClient.Connect();
       sftpClient.Disconnect();
    }
}
catch (Exception e)
{
    Console.WriteLine(e.Message);
}

但是当我运行代码时,出现以下错误:

The server response contains a null character at position 0x00000028:  
00000000  53 53 48 2D 32 2E 30 2D 4F 70 65 6E 53 53 48 5F  SSH-2.0-OpenSSH_  
00000010  37 2E 34 70 31 20 44 65 62 69 61 6E 2D 31 30 2B  7.4p1 Debian-10+  
00000020  64 65 62 39 75 32 0A 00                          deb9u2..  
A server must not send a null character before the Protocol Version Exchange is complete.

我不知道如何解决它,手动使用 WinSCP 时它工作正常,当使用 WinSCP.NET 时,它与代码一起工作也很好。但是我不能在 Linux 发行版上使用 WinSCP.NET。

所以有人知道出了什么问题吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)