1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_SSH_PRIVATE_KEYFILE 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_SSH_AUTH_TYPES (3) 9 - CURLOPT_SSH_PUBLIC_KEYFILE (3) 10Protocol: 11 - SFTP 12 - SCP 13--- 14 15# NAME 16 17CURLOPT_SSH_PRIVATE_KEYFILE - private key file for SSH auth 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PRIVATE_KEYFILE, 25 char *filename); 26~~~ 27 28# DESCRIPTION 29 30Pass a char pointer pointing to a *filename* for your private key. If not 31used, libcurl defaults to **$HOME/.ssh/id_rsa** or **$HOME/.ssh/id_dsa** if 32the HOME environment variable is set, and in the current directory if HOME is 33not set. 34 35If the file is password-protected, set the password with 36CURLOPT_KEYPASSWD(3). 37 38The SSH library derives the public key from this private key when possible. If 39the SSH library cannot derive the public key from the private one and no 40public one is provided with CURLOPT_SSH_PUBLIC_KEYFILE(3), the transfer 41fails. 42 43The application does not have to keep the string around after setting this 44option. 45 46# DEFAULT 47 48As explained above 49 50# EXAMPLE 51 52~~~c 53int main(void) 54{ 55 CURL *curl = curl_easy_init(); 56 if(curl) { 57 CURLcode res; 58 curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file"); 59 curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, 60 "/home/clarkkent/.ssh/id_rsa"); 61 curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password"); 62 res = curl_easy_perform(curl); 63 curl_easy_cleanup(curl); 64 } 65} 66~~~ 67 68# AVAILABILITY 69 70Added in 7.16.1 71 72# RETURN VALUE 73 74Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or 75CURLE_OUT_OF_MEMORY if there was insufficient heap space. 76