CURLOPT_SSH_PRIVATE_KEYFILE.3 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .\" generated by cd2nroff 0.1 from CURLOPT_SSH_PRIVATE_KEYFILE.md
  2. .TH CURLOPT_SSH_PRIVATE_KEYFILE 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_SSH_PRIVATE_KEYFILE \- private key file for SSH auth
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PRIVATE_KEYFILE,
  9. char *filename);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a char pointer pointing to a \fIfilename\fP for your private key. If not
  13. used, libcurl defaults to \fB$HOME/.ssh/id_rsa\fP or \fB$HOME/.ssh/id_dsa\fP if
  14. the HOME environment variable is set, and in the current directory if HOME is
  15. not set.
  16. If the file is password\-protected, set the password with
  17. \fICURLOPT_KEYPASSWD(3)\fP.
  18. The SSH library derives the public key from this private key when possible. If
  19. the SSH library cannot derive the public key from the private one and no
  20. public one is provided with \fICURLOPT_SSH_PUBLIC_KEYFILE(3)\fP, the transfer
  21. fails.
  22. The application does not have to keep the string around after setting this
  23. option.
  24. .SH DEFAULT
  25. As explained above
  26. .SH PROTOCOLS
  27. This functionality affects scp and sftp
  28. .SH EXAMPLE
  29. .nf
  30. int main(void)
  31. {
  32. CURL *curl = curl_easy_init();
  33. if(curl) {
  34. CURLcode res;
  35. curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
  36. curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE,
  37. "/home/clarkkent/.ssh/id_rsa");
  38. curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password");
  39. res = curl_easy_perform(curl);
  40. curl_easy_cleanup(curl);
  41. }
  42. }
  43. .fi
  44. .SH AVAILABILITY
  45. Added in curl 7.16.1
  46. .SH RETURN VALUE
  47. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  48. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  49. .SH SEE ALSO
  50. .BR CURLOPT_SSH_AUTH_TYPES (3),
  51. .BR CURLOPT_SSH_PUBLIC_KEYFILE (3)