1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at https://curl.haxx.se/docs/copyright.html.
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
21 .\" **************************************************************************
23 .TH CURLOPT_SSH_KEYFUNCTION 3 "19 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
25 CURLOPT_SSH_KEYFUNCTION \- callback for known host matching logic
28 #include <curl/curl.h>
31 CURLKHSTAT_FINE_ADD_TO_FILE,
33 CURLKHSTAT_REJECT, /* reject the connection, return an error */
34 CURLKHSTAT_DEFER, /* do not accept it, but we can't answer right
35 now so this causes a CURLE_DEFER error but
36 otherwise the connection will be left intact
41 CURLKHMATCH_OK, /* match */
42 CURLKHMATCH_MISMATCH, /* host found, key mismatch! */
43 CURLKHMATCH_MISSING, /* no matching host/key found */
47 const char *key; /* points to a zero-terminated string encoded with
48 base64 if len is zero, otherwise to the "raw"
51 enum curl_khtype keytype;
54 int ssh_keycallback(CURL *easy,
55 const struct curl_khkey *knownkey,
56 const struct curl_khkey *foundkey,
60 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYFUNCTION,
63 Pass a pointer to your callback function, which should match the prototype
66 It gets called when the known_host matching has been done, to allow the
67 application to act and decide for libcurl how to proceed. The callback will
68 only be called if \fICURLOPT_SSH_KNOWNHOSTS(3)\fP is also set.
70 This callback function gets passed the CURL handle, the key from the
71 known_hosts file \fIknownkey\fP, the key from the remote site \fIfoundkey\fP,
72 info from libcurl on the matching status and a custom pointer (set with
73 \fICURLOPT_SSH_KEYDATA(3)\fP). It MUST return one of the following return
74 codes to tell libcurl how to act:
76 .IP CURLKHSTAT_FINE_ADD_TO_FILE
77 The host+key is accepted and libcurl will append it to the known_hosts file
78 before continuing with the connection. This will also add the host+key combo
79 to the known_host pool kept in memory if it wasn't already present there. The
80 adding of data to the file is done by completely replacing the file with a new
81 copy, so the permissions of the file must allow this.
83 The host+key is accepted libcurl will continue with the connection. This will
84 also add the host+key combo to the known_host pool kept in memory if it wasn't
85 already present there.
87 The host+key is rejected. libcurl will deny the connection to continue and it
90 The host+key is rejected, but the SSH connection is asked to be kept alive.
91 This feature could be used when the app wants to somehow return back and act
92 on the host+key situation and then retry without needing the overhead of
93 setting it up from scratch again.
103 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
105 .BR CURLOPT_SSH_KEYDATA "(3), " CURLOPT_SSH_KNOWNHOSTS "(3), "