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

How to use SFTP (without server validation)

The topic How to use SFTP (introduction) describes the SFTP features of SecureFTPConnection. This topic demonstrates the use of SFTP without server validation. Server validation should always be used in a production environment, but disabling it is a good way of getting started.

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.

Using SFTP without server validation is simply a matter of setting the Protocol and ServerValidation properties as follows:

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

The first line tells SecureFTPConnection that it is to use SFTP and the second line that it should not try to validate the server's public key.


The UserName and Password must also be set, along with the ServerAddress. Note that some SFTP servers are set up to disallow password authentication, in which case the connection attempt will fail unless password authentication is enabled in the server configuration file.

After this a secure connection is established by simply calling Connect():

ftpConnection.Connect();