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