GNURLOPT_S...TE_KEYFILE(3)
π 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
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2014, 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms