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
13Added-in: 7.19.6
14---
15
16# NAME
17
18CURLOPT_SSH_KEYDATA - pointer passed to the SSH key callback
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYDATA, void *pointer);
26~~~
27
28# DESCRIPTION
29
30Pass a void * as parameter. This *pointer* is passed along verbatim to the
31callback set with CURLOPT_SSH_KEYFUNCTION(3).
32
33# DEFAULT
34
35NULL
36
37# %PROTOCOLS%
38
39# EXAMPLE
40
41~~~c
42struct mine {
43  void *custom;
44};
45static 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
56int 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
75Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
76