CURLOPT_SSH_KEYDATA.md (1654B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_SSH_KEYDATA 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_SSH_KEYDATA (3) 9 - CURLOPT_SSH_KNOWNHOSTS (3) 10 Protocol: 11 - SFTP 12 - SCP 13 Added-in: 7.19.6 14 --- 15 16 # NAME 17 18 CURLOPT_SSH_KEYDATA - pointer passed to the SSH key callback 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYDATA, void *pointer); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a void * as parameter. This *pointer* is passed along verbatim to the 31 callback set with CURLOPT_SSH_KEYFUNCTION(3). 32 33 # DEFAULT 34 35 NULL 36 37 # %PROTOCOLS% 38 39 # EXAMPLE 40 41 ~~~c 42 struct mine { 43 void *custom; 44 }; 45 static int keycb(CURL *easy, 46 const struct curl_khkey *knownkey, 47 const struct curl_khkey *foundkey, 48 enum curl_khmatch match, 49 void *clientp) 50 { 51 /* 'clientp' points to the callback_data struct */ 52 /* investigate the situation and return the correct value */ 53 return CURLKHSTAT_FINE_ADD_TO_FILE; 54 } 55 56 int main(void) 57 { 58 CURL *curl = curl_easy_init(); 59 if(curl) { 60 struct mine callback_data; 61 curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt"); 62 curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb); 63 curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data); 64 curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts"); 65 66 curl_easy_perform(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).