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
13Added-in: 7.19.6
14---
15
16# NAME
17
18CURLOPT_SSH_KNOWNHOSTS - filename holding the SSH known hosts
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KNOWNHOSTS, char *fname);
26~~~
27
28# DESCRIPTION
29
30Pass a pointer to a null-terminated string holding the filename of the
31known_host file to use. The known_hosts file should use the OpenSSH file
32format as supported by libssh2. If this file is specified, libcurl only
33accepts connections with hosts that are known and present in that file, with a
34matching public key. Use CURLOPT_SSH_KEYFUNCTION(3) to alter the default
35behavior on host and key matches and mismatches.
36
37The application does not have to keep the string around after setting this
38option.
39
40Using this option multiple times makes the last set string override the
41previous ones. Set it to NULL to disable its use again.
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_KNOWNHOSTS,
59                     "/home/clarkkent/.ssh/known_hosts");
60    res = curl_easy_perform(curl);
61    curl_easy_cleanup(curl);
62  }
63}
64~~~
65
66# %AVAILABILITY%
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