Discuss this help topic in SecureBlackbox Forum
Initiate the SFTP connection
To initiate the SFTP connection using simple SFTP, you need to use TElSimpleSFTPClient component. This component can use built-in socket mechanisms, and alternatively it lets you provide your own data transport.
TElSimpleSFTPClient incapsulates SSH protocol and all supplementary objects.
First of all you need to create an instance of TElSimpleSFTPClient class.
If you use built-in sockets, you need to set Address and Port properties of TElSimpleSFTPClient class to the address and port of the remote server. Also you need to set UseInternalSocket property of TElSimpleSFTPClient class to true.
If you want to use custom sockets, set UseInternalSocket property of TElSimpleSFTPClient class to false. Then assign the event handlers for OnSend, OnReceive and OnCloseConnection events of TElSimpleSFTPClient class. OnSend event is fired when the component needs to send the data to the remote server. OnReceive is fired when the component is ready to receive the remote data. OnCloseConnection is fired, if the component has closed protocol-level connection and requires that you close socket connection.
Next step is to setup connection and authentication properties. For decription of how to setup connection properties, see the corresponding how-to article. For decription of how to setup authentication properties, see the corresponding how-to article.
To handle protocol errors, which happen during connection, assign a handler to OnError event of TElSimpleSFTPClient class. Socket errors are not reported using OnError event, but only via exceptions.
The final step is to call Open() method of TElSimpleSFTPClient class. This method is synchronous and returns when the connection is established. If the connection could not be established, the exception happens.