GNURLOPT_SSH_KNOWNHOSTS(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’– 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