1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_SSH_KNOWNHOSTS
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_SSH_AUTH_TYPES (3)
9  - CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 (3)
10Protocol:
11  - SFTP
12  - SCP
13---
14
15# NAME
16
17CURLOPT_SSH_KNOWNHOSTS - filename holding the SSH known hosts
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KNOWNHOSTS, char *fname);
25~~~
26
27# DESCRIPTION
28
29Pass a pointer to a null-terminated string holding the filename of the
30known_host file to use. The known_hosts file should use the OpenSSH file
31format as supported by libssh2. If this file is specified, libcurl only
32accepts connections with hosts that are known and present in that file, with a
33matching public key. Use CURLOPT_SSH_KEYFUNCTION(3) to alter the default
34behavior on host and key matches and mismatches.
35
36The application does not have to keep the string around after setting this
37option.
38
39# DEFAULT
40
41NULL
42
43# EXAMPLE
44
45~~~c
46int main(void)
47{
48  CURL *curl = curl_easy_init();
49  if(curl) {
50    CURLcode res;
51    curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
52    curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS,
53                     "/home/clarkkent/.ssh/known_hosts");
54    res = curl_easy_perform(curl);
55    curl_easy_cleanup(curl);
56  }
57}
58~~~
59
60# AVAILABILITY
61
62Added in 7.19.6
63
64# RETURN VALUE
65
66Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
67CURLE_OUT_OF_MEMORY if there was insufficient heap space.
68