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