CURLOPT_SSH_HOST_PUBLIC_KEY_MD5(3)

✨ NAME ✨

Okay bestie, this is CURLOPT_SSH_HOST_PUBLIC_KEY_MD5(3) from the libcurl Library Functions Manual β€” the glow-up guide to checking an SSH server’s public key with an MD5 checksum. πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

       #include <curl/curl.h>

       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5,
                                 char *md5);

πŸ’– DESCRIPTION πŸ’–

So you pass a char pointer that points at a string containing 32 hexadecimal digits. That string should be the 128 bit MD5 checksum of the remote host’s public key, and then libcurl literally aborts the connection to the host unless the MD5 checksum match. Yes, it’s a whole vibe check for the key. 🫢

🚨 Bestie, MD5 is a weak algorithm. We strongly recommend using CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256(3) instead. Like, for real, use the SHA256 one. 😭

The application does not have to keep the string around after setting this option. So no stressing about its lifetime after you set it. πŸ’†

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, and NULL is the off switch. 🌈

🌸 DEFAULT 🌸

NULL

Yep, default is NULL, bestie. πŸŽ€

πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects scp and sftp. πŸ¦‹

⭐ EXAMPLE ⭐

Here’s the exact example β€” main character energy, but make it SFTP:

       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_MD5,
                            "afe17cd62a0f3b61f1ab9cb22ba269a7");
           result = curl_easy_perform(curl);
           curl_easy_cleanup(curl);
         }
       }

πŸ‘‘ AVAILABILITY πŸ‘‘

Added in curl 7.17.1. Iconic. πŸ’…

πŸ”₯ 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). So 0 = slay, non-zero = check the error code, bestie. 😭

🌈 SEE ALSO 🌈


That’s the whole page, bestie. Stay safe out there and remember: MD5 is weak, SHA256 is the moment. πŸ’– This was libcurl, dated 2026-10-12. πŸŽ€

πŸ“¦ where this page comes from