GNURLOPT_SSH_KNOWNHOSTS(3)
π CURLOPT_SSH_KNOWNHOSTS π
okay so bestie, this is the GNURLOPT_SSH_KNOWNHOSTS(3) page from the curl_easy_setopt options manual, and it's literally all about telling libcurl where your SSH known hosts file lives. iconic behavior, no cap. π
β¨ NAME β¨
CURLOPT_SSH_KNOWNHOSTS β file name holding the SSH known hosts. that's the whole vibe. π
π SYNOPSIS π
the signature is giving exactly this:
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KNOWNHOSTS, char
*fname);
π¦ DESCRIPTION π¦
Pass a pointer to a null-terminated string holding the file name of the known_host file to use. yes bestie, a pointer to a null-terminated string β we love a classic. π«Ά
The known_hosts file should use the OpenSSH file format as supported by libssh2. If this file is specified, libcurl will only accept connections with hosts that are known and present in that file, with a matching public key. so it's lowkey a vibe check for hosts, and the matching public key has to pass too. π₯
Use CURLOPT_SSH_KEYFUNCTION(3) to alter the default behavior on host and key (mis)matching. that's your little customization hook, iykyk. π
The application does not have to keep the string around after setting this option. cute, convenient, main character energy. β¨
π DEFAULT π
NULL
literally no file set by default, bestie. periodt. π
π PROTOCOLS π
SFTP and SCP
that's the protocol vibe check. π¦
πΈ EXAMPLE πΈ
here's the whole little snippet, exactly:
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS,
"/home/clarkkent/.ssh/known_hosts");
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
β AVAILABILITY β
Added in 7.19.6
vintage but iconic, ngl. β¨
π RETURN VALUE π
Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space. fr fr, those are the exact return values and we are not playing with them. π
π«Ά SEE ALSO π«Ά
the raw SEE ALSO list is literally CURLOPT_SSH_AUTH_TYPES(3), CURLOPT_SSH_HOST_PUBLIC_KEY_MD5(3), β yes, with that trailing comma, and we respect it. π
okay that's the page! signing off from libcurl 7.37.0, dated 19 Jun 2014 β mwah, slay, bye bestie ππ¦
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms