1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_SSH_KEYDATA 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_SSH_HOSTKEYFUNCTION (3) 9--- 10 11# NAME 12 13CURLOPT_SSH_HOSTKEYDATA - pointer to pass to the SSH host key callback 14 15# SYNOPSIS 16 17~~~c 18#include <curl/curl.h> 19 20CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYDATA, void *pointer); 21~~~ 22 23# DESCRIPTION 24 25Pass a void * as parameter. This *pointer* is passed along untouched to 26the callback set with CURLOPT_SSH_HOSTKEYFUNCTION(3). 27 28# DEFAULT 29 30NULL 31 32# PROTOCOLS 33 34SCP and SFTP 35 36# EXAMPLE 37 38~~~c 39struct mine { 40 void *custom; 41}; 42 43static int hostkeycb(void *clientp, /* CURLOPT_SSH_HOSTKEYDATA */ 44 int keytype, /* CURLKHTYPE */ 45 const char *key, /* host key to check */ 46 size_t keylen) /* length of the key */ 47{ 48 /* 'clientp' points to the callback_data struct */ 49 /* investigate the situation and return the correct value */ 50 return CURLKHMATCH_OK; 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_HOSTKEYFUNCTION, hostkeycb); 60 curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data); 61 62 curl_easy_perform(curl); 63 } 64} 65~~~ 66 67# AVAILABILITY 68 69Added in 7.84.0, works only with libssh2 backend. 70 71# RETURN VALUE 72 73Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 74