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
13Added-in: 7.16.1
14---
15
16# NAME
17
18CURLOPT_SSH_PUBLIC_KEYFILE - public 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_PUBLIC_KEYFILE,
26                          char *filename);
27~~~
28
29# DESCRIPTION
30
31Pass a char pointer pointing to a *filename* for your public key. If not used,
32libcurl defaults to **$HOME/.ssh/id_dsa.pub** if the HOME environment variable
33is set, and just "id_dsa.pub" in the current directory if HOME is not set.
34
35If NULL (or an empty string) is passed to this option, libcurl passes no
36public key to the SSH library, which then rather derives it from the private
37key. If the SSH library cannot derive the public key from the private one and
38no public one is provided, the transfer fails.
39
40The application does not have to keep the string around after setting this
41option.
42
43# DEFAULT
44
45NULL
46
47# %PROTOCOLS%
48
49# EXAMPLE
50
51~~~c
52int main(void)
53{
54  CURL *curl = curl_easy_init();
55  if(curl) {
56    CURLcode res;
57    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
58    curl_easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE,
59                     "/home/clarkkent/.ssh/id_rsa.pub");
60    res = curl_easy_perform(curl);
61    curl_easy_cleanup(curl);
62  }
63}
64~~~
65
66# HISTORY
67
68The "" trick was added in 7.26.0
69
70# %AVAILABILITY%
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