0 votes
by (320 points)

Hello Team,

While connecting to the FTP server: and port: 990, we are receiving the below error from Rebex component.

20:02:45.777 Info Info: Connecting to using Sftp 3.0.4546.0.
20:02:47.336 Error SSH: Rebex.Net.SshException: The connection was closed by the server. Make sure you are connecting to an SSH or SFTP server.
at Rebex.Net.SshSession.14Ad4fZ()
at Rebex.Net.SshSession.Negotiate()


But when we connect the same server with File Zilla, we are able to connect it. Please help us to connect it from Rebex. Thank you.

We look forward to your reply.

Naga Suresh D

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (145k points)

Hello, is not an SFTP/SSH server. It's an FTP server implicitly secured with TLS. Please use Rebex FTP/SSL to connect to this server:

var ftp = new Ftp();
ftp.Connect("", 990, SslMode.Implicit);

Alternatively, you might use FileTransferClient (part of Rebex File Transfer Pack) which (like FileZilla) supports both FTP and SFTP:

var client = new FileTransferClient();
client.Connect("", 990, FileTransferMode.FtpSslImplicit);

If you get an exception indicating that the server certificate was rejected, check out this blog post: https://blog.rebex.net/howto-server-certificate-rejected-exception/

by (320 points)
Please confirm the above clarification. Thank you.
by (320 points)
How can we know programmatically the FTP server is FTP/SSL/SFTP? So that we will dynamically use the connection object as per the requirement. Thank you.
by (145k points)
We commented on SslAcceptAllCertificates in the blog post with these words: "Doing this in production environment is highly discouraged, as it effectively disables server authentication."

However, that was in 2012. Today, our recommendation for most scenarios is even stronger: "NEVER use 'SslAcceptAllCertificates=true' in production! Doing so enables man-in-the-middle attacks and essentially renders TLS/SSL completely useless."

The property is useful when testing or debugging because it makes it possible to determine whether the application would work if certificate validation succeeded, but don't use it in production environments unless the connection between to the client and server is sufficiently secure even without TLS/SSL. In other words, only enable SslAcceptAllCertificates if not using TLS/SSL at all would be acceptable as well.
by (70.3k points)
To determine what service is running at the server, the only way is to try it.
So, you can try SFTP, if Connect() method fails try FTP/SSL. If this fails try plain FTP.

However, I suggest you to determine the protocol by port number at first.

Common port numbers:
  22 - SFTP
  21 - FTP (and FTP/SSL explicit)
  990 - FTP/SSL implicit
by (320 points)
We will verify the FTP server with the port and the above logic. Thank you.