CURLOPT_SS...KEY_SHA256(3)

πŸ’– CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256(3) πŸ’–

okay bestie, this cutie comes straight out of the Library Functions Manual, and it's here to check the SHA256 hash of an SSH server's public key. no cap. ✨


🌸 NAME 🌸

CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 β€” SHA256 hash of SSH server public key.


✨ SYNOPSIS ✨

       #include <curl/curl.h>

       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256,
                                 char *sha256);

πŸ’… DESCRIPTION πŸ’…

You pass a char pointer pointing to a string containing a Base64-encoded SHA256 hash of the remote host's public key. The transfer fails if the given hash does not match the hash the remote host provides. 🫢

The application does not have to keep the string around after setting this option. So you can let it go after setting it β€” she's done her job. πŸ’…

Using this option multiple times makes the last set string override the previous ones. Set it to NULL to disable its use again. Last one wins, periodt. πŸ‘‘


πŸ“ DEFAULT πŸ“

NULL


πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects scp and sftp. 🧚


πŸ”₯ EXAMPLE πŸ”₯

       int main(void)
       {
         CURL *curl = curl_easy_init();
         if(curl) {
           CURLcode result;
           curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
           curl_easy_setopt(curl, CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256,
                            "NDVkMTQxMGQ1ODdmMjQ3MjczYjAyOTY5MmRkMjVmNDQ=");
           result = curl_easy_perform(curl);
           curl_easy_cleanup(curl);
         }
       }

πŸ’€ NOTES πŸ’€

Requires the libssh2 backend. so like, no libssh2, no vibe check. 😭


πŸ‘‘ AVAILABILITY πŸ‘‘

Added in curl 7.80.0. ⭐


🌈 RETURN VALUE 🌈

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). πŸ’–


🫢 SEE ALSO 🫢


mwah πŸ’‹ this page is from source/version libcurl, dated 2026-10-12, and its footer title is CURLOPT_SS...KEY_SHA256(3). bye bestie, go check those hashes πŸ’œ

πŸ“¦ where this page comes from