CURLOPT_SSH_KNOWNHOSTS.md (1891B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_SSH_KNOWNHOSTS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_SSH_AUTH_TYPES (3) 9 - CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3) 10 - CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 (3) 11 Protocol: 12 - SFTP 13 - SCP 14 Added-in: 7.19.6 15 --- 16 17 # NAME 18 19 CURLOPT_SSH_KNOWNHOSTS - filename holding the SSH known hosts 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KNOWNHOSTS, char *fname); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a pointer to a null-terminated string holding the filename of the 32 known_host file to use. The known_hosts file should use the OpenSSH file 33 format. If this file is specified, libcurl only accepts connections with hosts 34 that are known and present in that file, with a matching public key. Use 35 CURLOPT_SSH_KEYFUNCTION(3) to alter the default behavior on host and key 36 matches and mismatches. 37 38 We strongly suggest users doing SCP or SFTP transfers to set this option to 39 make sure that the network communication is done with the intended server and 40 not an impostor. 41 42 The application does not have to keep the string around after setting this 43 option. 44 45 Using this option multiple times makes the last set string override the 46 previous ones. Set it to NULL to disable its use again. 47 48 # DEFAULT 49 50 NULL 51 52 # %PROTOCOLS% 53 54 # EXAMPLE 55 56 ~~~c 57 int main(void) 58 { 59 CURL *curl = curl_easy_init(); 60 if(curl) { 61 CURLcode res; 62 curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); 63 curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, 64 "/home/clarkkent/.ssh/known_hosts"); 65 res = curl_easy_perform(curl); 66 curl_easy_cleanup(curl); 67 } 68 } 69 ~~~ 70 71 # %AVAILABILITY% 72 73 # RETURN VALUE 74 75 curl_easy_setopt(3) returns a CURLcode indicating success or error. 76 77 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 78 libcurl-errors(3).