I'm trying to use Renci SSH.NET to connect to an FTP site and download files from my C# app. I can successfully connect to the host with FileZilla and WinSCP (on Windows 10 Pro 64), and through an HTTP connection (the host is running CrushFTP), but cannot figure out how to successfully connect from my C# app, using SSH.NET. I'm getting this error:
The server response contains a null character at position 0x00000004: 00000000 15 03 03 00....A server must not send a null character before the Protocol Version Exchange is complete.
My take on the documentation from here, is that this problem appears to be an expected error. I've read the information suggested by the documentation at https://www.rfc-editor.org/rfc/rfc4253#section-4.2 and I "think" I understand that to mean that the host that I'm trying to connect to may not be correctly configured. My question is, since I don't have the ability to change how the host is configured, whether there is a way around this error with the SSH.NET library or am I just at a dead end for using SSH.NET?
Here's my code - tried to simplify to bare minimum:
using System;
using Renci.SshNet;
namespace mysftp
{
class Program
{
static void Main(string[] args)
{
string host = "myftps.hostname.com";
string username = "myusername";
string password = "securepassword";
int port = 990;
string remoteFolder = "/";
using (SftpClient sftp = new SftpClient(host, port, username, password))
{
try
{
Console.WriteLine("Attempting to connect to " + host + " ...");
sftp.Connect();
Console.WriteLine(sftp.ConnectionInfo.ServerVersion);
sftp.Disconnect();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}
}
}
Here is the host information (Remote server info from WinSCP):
Remote system = UNIX Type: L8
File transfer protocol = FTP
Cryptographic protocol = TLS/SSL Implicit encryption, TLSv1.2
Encryption algorithm = TLSv1.2: ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA, ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD
Compression = No
------------------------------------------------------------
Certificate fingerprint
<<fingerprint info redacted>>
------------------------------------------------------------
Can change permissions = Yes
Can change owner/group = No
Can execute arbitrary command = Protocol commands only
Can create symbolic/hard link = No/No
Can lookup user groups = No
Can duplicate remote files = No
Can check available space = No
Can calculate file checksum = Yes
Native text (ASCII) mode transfers = No
------------------------------------------------------------
Additional information
The server supports these FTP additional features:
AUTH TLS
AUTH SSL
SSCN
PBSZ
PROT
CCC
CLNT
EPSV
EPRT
MDTM
MDTM YYYYMMDDHHMMSS[+-TZ];filename
MFMT
SIZE
REST STREAM
MODE Z
LIST -Q
SITE UTIME
SITE MD5
XMD5
SITE MD5s
SITE RANDOMACCESS
MLST Type*;Size*;Modify*;Perm*;UNIX.owner*;UNIX.group*;
UTF8