GNURLOPT_S...TE_KEYFILE(3)

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

πŸ’– CURLOPT_SSH_PRIVATE_KEYFILE - set private key file for SSH auth πŸ’–

okay so bestie, you found the GNURLOPT_S...TE_KEYFILE(3) page in the curl_easy_setopt options fam πŸ’… and it's literally all about telling libcurl which private key file to use for SSH auth. no cap, this is the keyfile hookup. ✨

🌸 NAME 🌸

CURLOPT_SSH_PRIVATE_KEYFILE - set private key file for SSH auth 🫢

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PRIVATE_KEYFILE,
                          char *filename);

πŸŽ€ DESCRIPTION πŸŽ€

Pass a char * pointing to a filename for your private key. πŸ—οΈ If you don't use this option, libcurl defaults to $HOME/.ssh/id_dsa if the HOME environment variable is set, and just "id_dsa" in the current directory if HOME is not set. It's giving "libcurl has a backup plan" and honestly? iconic. 🌈

If the file is password-protected, set the password with CURLOPT_KEYPASSWD(3). πŸ”

The application does not have to keep the string around after setting this option β€” set it, then you can let that string go, fr fr. πŸ’…

πŸ’« DEFAULT πŸ’«

As explained above, bestie. That's the whole default vibe β€” lowkey simple, highkey exactly what the description said. πŸ’–

πŸ¦‹ PROTOCOLS πŸ¦‹

SFTP and SCP β€” that's it, that's the guest list. πŸŽ€

πŸ“ EXAMPLE πŸ“

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
  curl_easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE,
                   "/home/clarkkent/.ssh/id_rsa");
  curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password");
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

⭐ AVAILABILITY ⭐

Added in 7.16.1 β€” a certified classic, your honor. πŸ‘‘

πŸ”₯ 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. So: slay, unsupported, or out of memory β€” those are the three moods. 😭

πŸ’œ SEE ALSO πŸ’œ


mwah πŸ’‹ this little page is from libcurl 7.37.0, dated 19 Jun 2014 β€” yes, she's vintage, and she still ate. bye bestie, go set that keyfile 🫢✨

πŸ“¦ where this page comes from