I am trying to connect to an SFTP server using SSH.NET (2020.0.0).
My code looks as simple as this:
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);
}
But when I run the code, I get following error:
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.
I have no clue how to solve it, when using WinSCP manually it works fine, when using WinSCP.NET, it works fine as well with code. But I can not use WinSCP.NET on a Linux distribution.
So anyone got an idea what's wrong?