SftpClient() // object constructor


This function creates and returns a new SftpClient object, which is the AFT object that implements and carries out all file transfers and related operations using the SFTP protocol.


Here's the protocol-specific properties that you may have to initialize/configure before calling the .Connect() method:


Host           string
User           string
Pass           string
PassFromSecret string
KeyFile        string
KeyFilePass    string
KeyFileSecret  string


Host: is the IP address or HostName and Port of the remote file server. Should always be specified in the form IP:Port or Host:Port format. Examples: 192.168.2.23:22 or sftp.mycompany.com:22.


User: this is the username to access the remote server. If the server uses APIKey/APISecret instead of Username/Password, this property will contain the APIKey.


Pass: this is the password to access the remote server. If the server uses APIKey/APISecret instead of Username/Password, this property will contain the APISecret.


PassFromSecret: Syncplify.me AFT! allows you to store secrets (strings) in its encrypted database, so you don't have to put them in clear in your scripts. If you have stored a host's password (or APISecret) as an encrypted secret in Syncplify.me AFT! you can reference it via PassFromSecret to retrieve it at runtime without typing it in plain-text in your script. Read more about secrets.


KeyFile: if you specify the fully qualified path to a file containing your private key (in RSA format) then the client object will attempt PKI authentication. Leave this property empty/blank to authenticate via simple username and password.


KeyFilePass: if you have specified a KeyFile, and if the KeyFile is password-protected (encrypted), this is the password that's necessary to decrypt such file.


KeyFileSecret: if you have specified a KeyFile, and if the KeyFile is password-protected (encrypted), this is the name of the secret object in Syncplify.me AFT!'s database that corresponds to the KeyFile's password, so you don't have to type such password in clear in your script. Using "secrets" is always the recommended method to specify passwords in Syncplify.me AFT! Read more about secrets.


Please, keep in mind that once created you (the programmer) have the responsibility of freeing the memory allocated by the object at the end of its use. You can easily do so by simply setting the object to null once you're done using it (as shown in the example below).

Example:

{
 var scli = new SftpClient();
 scli.Host = 'your.sftpserver.com:22';
 scli.User = 'someusername';
 scli.KeyFile = './my_id.rsa';
 if (scli.Connect()) {
  // perform your file transfers...
  // ...
  // ...
  scli.Close();
 }
 scli = null
}