GNURLOPT_SSH_KEYDATA(3)

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

✨ GNURLOPT_SSH_KEYDATA(3) ✨

okay so this is a page from the curl_easy_setopt options manual, bestie β€” yes that curl, the one your whole internet runs on β€” and today's topic is a lil' pointer that just... rides along. πŸŽ€


πŸ’– NAME πŸ’–

CURLOPT_SSH_KEYDATA β€” the pointer you hand off to the SSH key callback, no questions asked, no cap 🫢

🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_KEYDATA, void
*pointer);

πŸ¦‹ DESCRIPTION πŸ¦‹

so you pass a void * as the parameter. mmm yes pointer, iconic behavior. πŸ’…

and then? that pointer gets passed along verbatim to the callback you set with CURLOPT_SSH_KEYFUNCTION(3). verbatim verbatim. like, it doesn't get touched, it doesn't get copied, it doesn't get judged β€” it just shows up at the callback like "hi i'm here πŸ’". lowkey the most loyal option in the whole set ngl ✨

🧚 DEFAULT 🧚

NULL

(empty. blank. no pointer. it's giving "nothing to see here" 😭)

πŸ‘‘ PROTOCOLS πŸ‘‘

SFTP and SCP β€” ssh vibes only bestie 🌈

πŸ“ EXAMPLE πŸ“

ok so here's the whole moment, look at it:

static int keycb(CURL *easy,
                 const struct curl_khkey *knownkey,
                 const struct curl_khkey *foundkey,
                 enum curl_khmatch,
                 void *clientp)
{
  /* 'clientp' points to the callback_data struct */
  /* investigate the situation and return the correct value */
  return CURLKHSTAT_FINE_ADD_TO_FILE;
}
{
  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/thisfile.txt");
  curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, keycb);
  curl_easy_setopt(curl, CURLOPT_SSH_KEYDATA, &callback_data);
  curl_easy_setopt(curl, CURLOPT_SSH_KNOWNHOSTS, "/home/user/known_hosts");

  curl_easy_perform(curl);
}

see how &callback_data goes in as the keydata and then comes out the other side as clientp? yeah. that's the whole bit. the way that pointer just travels 😭🫢

⭐ AVAILABILITY ⭐

added in 7.19.6 β€” retro, vintage, a classic πŸ’œ

πŸ”₯ RETURN VALUE πŸ”₯

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. like, either we slay or we don't, there is no third option. πŸ’€

🌈 SEE ALSO 🌈

ok tiny heads up bestie β€” yeah that's the option itself listed in its own SEE ALSO, that's just what the page says, i don't make the rules πŸ™ˆ

and that's the page!! πŸŽ€βœ¨

this whole thing is from libcurl 7.37.0, dated 19 Jun 2014 β€” so if you're reading this in a group chat sometime later, know the lore is old but the vibes are forever πŸ’…πŸ¦‹β­

πŸ“¦ where this page comes from