CURLOPT_SSH_PRIVATE_KEYFILE(3)
π CURLOPT_SSH_PRIVATE_KEYFILE π
okay so bestie, this is a libcurl page from the Library Functions Manual, and it's about telling curl where your SSH private key lives. literally the whole vibe. β¨
πΈ NAME πΈ
CURLOPT_SSH_PRIVATE_KEYFILE β the private key file you use for SSH auth, no cap ποΈ
π SYNOPSIS π
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_PRIVATE_KEYFILE,
char *filename);
π¦ DESCRIPTION π¦
So you pass a char pointer that points to a filename β that's your private key, bestie. π
If you don't use this option, libcurl goes ahead and defaults to $HOME/.ssh/id_rsa or $HOME/.ssh/id_dsa if the HOME environment variable is set, and it looks in the current directory if HOME is not set. the way it just picks for you π
If the file is password-protected, set that password with CURLOPT_KEYPASSWD(3). don't leave her hanging. π«Ά
The SSH library derives the public key from this private key when it can. But listen β if the SSH library cannot derive the public key from the private one and no public one is provided with CURLOPT_SSH_PUBLIC_KEYFILE(3), the transfer fails. like, dead. π so give her what she needs.
Good news though: the application does not have to keep the string around after setting this option. set it and forget it, icon behavior β
π§ DEFAULT π§
As explained above β¨ (aka the $HOME/.ssh/id_rsa / $HOME/.ssh/id_dsa / current-directory situation)
π 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_PRIVATE_KEYFILE,
"/home/clarkkent/.ssh/id_rsa");
curl_easy_setopt(curl, CURLOPT_KEYPASSWD, "password");
result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
β AVAILABILITY β
Added in curl 7.16.1 π
π₯ 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) for the full tea.
π SEE ALSO π
okay that's the whole page, bestie, you ate π
β¨ this was libcurl, dated 2026-10-12, and the page is CURLOPT_SSH_PRIVATE_KEYFILE(3) β mwah, go forth and SSH π¦π
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms