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