CURLOPT_SSH_AUTH_TYPES(3)

πŸ’… CURLOPT_SSH_AUTH_TYPES(3) β€” bestie's guide to SFTP/SCP auth

okay so this is page CURLOPT_SSH_AUTH_TYPES(3) from the Library Functions Manual, and it's literally the glow-up your SSH connections needed ✨


🌸 NAME

CURLOPT_SSH_AUTH_TYPES β€” the auth types you get to use for SFTP and SCP πŸŽ€


πŸ¦‹ SYNOPSIS

#include <curl/curl.h>

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

πŸ’– DESCRIPTION

bestie, you pass a long here, and it's set to a bitmask β€” like a little stack of auth vibes you're combining together 🫢 β€” made of one or more of these:

  • CURLSSH_AUTH_PUBLICKEY
  • CURLSSH_AUTH_PASSWORD
  • CURLSSH_AUTH_HOST
  • CURLSSH_AUTH_KEYBOARD
  • CURLSSH_AUTH_AGENT

You can also set CURLSSH_AUTH_ANY to let libcurl pick a suitable one, like "you choose for me, king" πŸ‘‘.

and now the messy parts, no cap:

  • Currently CURLSSH_AUTH_HOST has no effect. it's giving decorative. πŸ’€
  • If CURLSSH_AUTH_AGENT is used, libcurl attempts to connect to ssh-agent or pageant and lets the agent attempt the authentication. agent energy, main character stuff 🧚

⭐ DEFAULT

CURLSSH_AUTH_ANY (all available) β€” literally all of them, she's generous 🌈


πŸ”₯ 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_AUTH_TYPES,
                     CURLSSH_AUTH_PUBLICKEY | CURLSSH_AUTH_KEYBOARD);
    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

look at her go, combining CURLSSH_AUTH_PUBLICKEY and CURLSSH_AUTH_KEYBOARD with a | like an absolute icon πŸŽ€


πŸ•°οΈ HISTORY

okay history lesson time, sit down πŸ“š β€” the CURLSSH_AUTH_* macros became long types in 8.16.0. Prior to that version, a long cast was necessary when passed to curl_easy_setopt(3). so glow-up era, basically ✨


🐣 AVAILABILITY

Added in curl 7.16.1 β€” vintage but still slaying πŸ’…


πŸ’« 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).


πŸ‘€ SEE ALSO

the friend group fr fr 🫢


πŸ’€ reminder bestie: CURLSSH_AUTH_HOST currently does nothing. don't be out here expecting it to work, iykyk.

that's the whole page, mwah 😘 β€” brought to you by libcurl, dated 2026-10-12, and filed under CURLOPT_SSH_AUTH_TYPES(3). go forth and authenticate, queen πŸ‘‘πŸ’–

πŸ“¦ where this page comes from