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

How to use SFTP (with client validation - password authentication)

The topic How to use SFTP (introduction) describes the SFTP features of SecureFTPConnection.  This topic demonstrates the use of SFTP with the simplest form of client validation - password authentication.

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.None;

If ServerValidation is set to Automatic then you should ensure that the server's public keys are loaded by the client as described in How to use SFTP (with server validation).

Client authentication can be either by password, by public/private keys, or by keyboard- interactive authentication. The default is password authentication.

The current authentication method can be found (and set) from SecureFTPConnection's AuthenticationMethod property. To set it to password authentication, use:

ftpConnection.AuthenticationMethod = AuthenticationType.Password;

In password authentication, SecureFTPConnection's UserName and Password properties must be set, along with the ServerAddress. The user name and password should be that of the SSH user that the client is logging in as.

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.

Public key authentication is discussed in How to use SFTP (with client validation - public key authentication).

Keyboard-interactive authentication is discussed in How to use SFTP (with client validation - keyboard-interactive authentication).