CURLOPT_SSH_KEYDATA.3 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSH_KEYDATA.md
  2. .TH CURLOPT_SSH_KEYDATA 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSH_KEYDATA \- pointer passed to the SSH key callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYDATA, void *pointer);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a void * as parameter. This \fIpointer\fP is passed along verbatim to the
  12. callback set with \fICURLOPT_SSH_KEYFUNCTION(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 keycb(CURL *easy,
  23. const struct curl_khkey *knownkey,
  24. const struct curl_khkey *foundkey,
  25. enum curl_khmatch match,
  26. void *clientp)
  27. {
  28. /* 'clientp' points to the callback_data struct */
  29. /* investigate the situation and return the correct value */
  30. return CURLKHSTAT_FINE_ADD_TO_FILE;
  31. }
  32. int main(void)
  33. {
  34. CURL *curl = curl_easy_init();
  35. if(curl) {
  36. struct mine callback_data;
  37. curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
  38. curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb);
  39. curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data);
  40. curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts");
  41. curl_easy_perform(curl);
  42. }
  43. }
  44. .fi
  45. .SH AVAILABILITY
  46. Added in curl 7.19.6
  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_KEYDATA (3),
  51. .BR CURLOPT_SSH_KNOWNHOSTS (3)