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