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