Method SFTPClient():new() Foundation

Initializes a new SFTP client instance.

Syntax
:new( <cUrl>, <cUsername>, [<cPassword>], [<cProxyUrl>] ) --> self
Parameters
<cUrl>
The URL of the SFTP server. The URL must contain the "sftp://" scheme prefix. Otherwise, the method raises a runtime error. When using a non-standard port, the port number must be specified in the URL (e.g., "sftp://example.com:2222").
<cUsername>
The username used for authentication.
<cPassword>
The password used for authentication. This parameter is optional. If a password is specified, username and password authentication is used when establishing the connection. If the password is omitted, a key file must be specified with the :setKeyFile() method, in which case public key authentication is performed.
<cProxyUrl>
An optional URL of a proxy server.
Return

This method returns self.

Description

Creates and initializes a new SFTP client instance for connecting to the specified server. To do this, this method requires the server URL and the credentials for user authentication to be specified.

Two different authentication methods are supported: via username and password or using public key authentication using a key file. In the latter case, the <cPassword> parameter is ignored. Instead, the :setKeyFile() method must be used to specify the key file used for authentication.

After creating the instance, you can configure SSH authentication using :setKeyFile() or :setKnownHostsFile() before establishing the connection with :connect().

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.