GNURLOPT_SSH_AUTH_TYPES(3)

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

πŸ’… GNURLOPT_SSH_AUTH_TYPES(3)

okay bestie, so this one lives in the curl_easy_setopt options section of the manual (yes, the gnurl-flavored one, we're fancy like that) β€” and it's literally all about telling SFTP and SCP how you wanna prove who you are. let's get into it 🫢


✨ NAME ✨

CURLOPT_SSH_AUTH_TYPES β€” set desired auth types for SFTP and SCP

✨ SYNOPSIS ✨

#include <gnurl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_AUTH_TYPES, long
bitmask);

✨ DESCRIPTION ✨

so you pass a long that's set to a bitmask (iykyk, it's giving "OR a bunch of flags together"), and that bitmask is made of one or more of these icons πŸ‘‘:

  • CURLSSH_AUTH_PUBLICKEY
  • CURLSSH_AUTH_PASSWORD
  • CURLSSH_AUTH_HOST
  • CURLSSH_AUTH_KEYBOARD
  • CURLSSH_AUTH_AGENT

if you'd rather not choose, set CURLSSH_AUTH_ANY and let libcurl pick a suitable one for you β€” main character energy, let the library decide πŸ’…

ngl, one thing to know: currently CURLSSH_AUTH_HOST has no effect. it's just kinda there, vibing πŸ¦‹

and if you use CURLSSH_AUTH_AGENT, libcurl attempts to connect to ssh-agent or pageant and lets the agent attempt the authentication. teamwork, slay πŸ’–

✨ DEFAULT ✨

None πŸ˜” (no default, you gotta tell it what you want)

✨ PROTOCOLS ✨

SFTP and SCP 🌸

✨ EXAMPLE ✨

CURL *curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_URL, "sftp://example.com/file");
  curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES,
                   CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD);
  ret = curl_easy_perform(curl);
  curl_easy_cleanup(curl);
}

look at that bitmask going off β€” CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD, iconic combo πŸ”₯

✨ AVAILABILITY ✨

  • CURLSSH_AUTH_HOST was added in 7.16.1
  • CURLSSH_AUTH_AGENT was added in 7.28.0

✨ RETURN VALUE ✨

returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's it, that's the vibe check ⭐

✨ SEE ALSO ✨


bestie reminder: CURLSSH_AUTH_HOST is currently a no-op, so don't build your whole personality around it πŸ™ˆ

mwah, that's the whole page πŸ’œ β€” brought to you by libcurl 7.37.0, dated 19 Jun 2014, filed under GNURLOPT_SSH_AUTH_TYPES(3). go forth and auth, queen πŸ‘‘πŸŽ€

πŸ“¦ where this page comes from