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