edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing

How to use SFTP (with server validation)

The topic How to use SFTP (introduction) describes the SFTP features of SecureFTPConnection.  This topic demonstrates the use of SFTP with server validation.

IMPORTANT: An SFTP compatible server is required for this example.  You can download a free trial of CompleteFTP, a Windows SFTP server, from this link.

As in How to use SFTP (without server validation), the Protocol and ServerValidation properties must be set:

ftpConnection.Protocol = FileTransferProtocol.SFTP;
ftpConnection.ServerValidation = SecureFTPServerValidationType.Automatic;

Setting ServerValidation to Automatic instructs SecureFTPConnection to compare the public key sent to the client by the server with the public keys that have been loaded by the client.

Public keys are managed by the client's KnownHostsManager, available in SecureFTPConnection's KnownHosts property.

There are two ways that the client can load server public keys - via the known_hosts file or by explicitly loading a public key from a file.