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