---
name: "CURLOPT_SSH_AUTH_TYPES"
section: "3"
platform: "linux"
package: "curl"
version: "8.23.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/CURLOPT_SSH_AUTH_TYPES"
---

# CURLOPT\_SSH\_AUTH\_TYPES(3)

auth types for SFTP and SCP

## NAME

CURLOPT\_SSH\_AUTH\_TYPES - auth types for SFTP and SCP

## SYNOPSIS

```
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SSH_AUTH_TYPES, long bitmask);
```

## DESCRIPTION

Pass a long set to a bitmask consisting of one or more of CURLSSH\_AUTH\_PUBLICKEY, CURLSSH\_AUTH\_PASSWORD, CURLSSH\_AUTH\_HOST, CURLSSH\_AUTH\_KEYBOARD and CURLSSH\_AUTH\_AGENT.

Set *CURLSSH\_AUTH\_ANY* to let libcurl pick a suitable one. Currently CURLSSH\_AUTH\_HOST has no effect. If CURLSSH\_AUTH\_AGENT is used, libcurl attempts to connect to ssh-agent or pageant and let the agent attempt the authentication.

## DEFAULT

CURLSSH\_AUTH\_ANY (all available)

## 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);
  }
}
```

## HISTORY

**CURLSSH\_AUTH\_**\* macros became *long* types in 8.16.0, prior to this version a *long* cast was necessary when passed to *[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)*.

## AVAILABILITY

Added in curl 7.16.1

## RETURN VALUE

*[curl\_easy\_setopt(3)](/curl_easy_setopt/3.md)* returns a CURLcode indicating success or error.

CURLE\_OK (0) means everything was OK, non-zero means an error occurred, see *[libcurl-errors(3)](/libcurl-errors/3.md)*.

## SEE ALSO

[**CURLOPT\_SSH\_HOST\_PUBLIC\_KEY\_MD5**(3)](/CURLOPT_SSH_HOST_PUBLIC_KEY_MD5/3.md), [**CURLOPT\_SSH\_HOST\_PUBLIC\_KEY\_SHA256**(3)](/CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256/3.md), [**CURLOPT\_SSH\_PUBLIC\_KEYFILE**(3)](/CURLOPT_SSH_PUBLIC_KEYFILE/3.md)
