Setting Up SFTP Public Key Authorization

The example below demonstrates how to set up the SFTP Public Key Authorization for the SFTP Client component.

sftp.Server := 'sftp-host';
sftp.Port := 22;

sftp.UserKey.Clear();
sftp.UserKey.PrivateKeyFile := 'rsa-private-key';
sftp.UserKey.PassPhrase := 'private-key-password';
sftp.UserName := 'user-name';

sftp.Open();

Alternatively, you can load the private key from a stream, Delphi string list, or array of bytes.

sftp.UserKey.Load(privateKeyBytes);

Add Feedback