Method SFTPClient():setKnownHostsFile() Foundation
Sets the known hosts file for SSH host verification.
:setKnownHostsFile( <cKnownHostsFile> ) --> self
This method returns self.
Sets an application-specific known hosts file which contains the public keys of trusted SFTP servers. The known hosts file is used to verify the authenticity of SFTP servers when a connection is established.
When a known host file is set using :setKnownHostsFile() and a connection is opened to a server, the server's host key is compared against the entries in the file. If the server's host key matches a known hosts entry, the connection succeeds. If there is no match, the connection is rejected.
Application-specific known hosts files can be used to only allow connections to a list of pre-defined SFTP servers. By default, no application-specific known hosts file is active and all connections are allowed.
The system also keeps a global list of known hosts for each user. When connecting to a SFTP server using SSH for the first time, the user's known hosts file is extended with the corresponding host information. This information can be extracted and copied into the application-specific known hosts file which can then be used with :setKnownHostsFile().
The user's global known hosts file ("known_hosts") is located in the folder %HOMEPATH%/.ssh by default.
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.