CURLOPT_SSH_HOSTKEYDATA.3 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSH_HOSTKEYDATA.md
  2. .TH CURLOPT_SSH_HOSTKEYDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSH_HOSTKEYDATA \- pointer to pass to the SSH host key callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOSTKEYDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a void * as parameter. This \fIpointer\fP is passed along untouched to
  12. the callback set with \fICURLOPT_SSH_HOSTKEYFUNCTION(3)\fP.
  13. .SH DEFAULT
  14. NULL
  15. .SH PROTOCOLS
  16. This functionality affects scp and sftp
  17. .SH EXAMPLE
  18. .nf
  19. struct mine {
  20. void *custom;
  21. };
  22. static int hostkeycb(void *clientp, /* CURLOPT_SSH_HOSTKEYDATA */
  23. int keytype, /* CURLKHTYPE */
  24. const char *key, /* host key to check */
  25. size_t keylen) /* length of the key */
  26. {
  27. /* 'clientp' points to the callback_data struct */
  28. /* investigate the situation and return the correct value */
  29. return CURLKHMATCH_OK;
  30. }
  31. int main(void)
  32. {
  33. CURL *curl = curl_easy_init();
  34. if(curl) {
  35. struct mine callback_data;
  36. curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
  37. curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYFUNCTION, hostkeycb);
  38. curl_easy_setopt(curl, CURLOPT_SSH_HOSTKEYDATA, &callback_data);
  39. curl_easy_perform(curl);
  40. }
  41. }
  42. .fi
  43. .SH NOTES
  44. Works only with the libssh2 backend.
  45. .SH AVAILABILITY
  46. Added in curl 7.84.0
  47. .SH RETURN VALUE
  48. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  49. .SH SEE ALSO
  50. .BR CURLOPT_SSH_HOSTKEYFUNCTION (3)