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