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