---
name: "libssh2_agent_sign"
section: "3"
platform: "linux"
package: "libssh2"
version: "1.11.1-7"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libssh2_agent_sign"
---

# libssh2\_agent\_sign(3)

sign data, with the help of ssh-agent

## NAME

libssh2\_agent\_sign - sign data, with the help of ssh-agent

## SYNOPSIS

```
#include <libssh2.h>
int
libssh2_agent_sign(LIBSSH2_AGENT *agent,
                   struct libssh2_agent_publickey *identity,
                   unsigned char **sig,
                   size_t *s_len,
                   const unsigned char *data,
                   size_t d_len,
                   const char *method,
                   unsigned int method_len);
```

## DESCRIPTION

*agent* - ssh-agent handle as returned by **[libssh2\_agent\_init(3)](/libssh2_agent_init/3.md)**

*identity* - Public key to authenticate with, as returned by **[libssh2\_agent\_get\_identity(3)](/libssh2_agent_get_identity/3.md)**

*sig* - A pointer to a buffer in which to place the signature. The caller is responsible for freeing the signature with LIBSSH2\_FREE.

*s\_len* - A pointer to the length of the sig parameter.

*data* - The data to sign.

*d\_len* - The length of the data parameter.

*method* - A buffer indicating the signing method. This should match the string at the start of identity-\>blob.

*method\_len* - The length of the method parameter.

Sign data using an ssh-agent. This function can be used in a callback registered with [libssh2\_session\_callback\_set2(3)](/libssh2_session_callback_set2/3.md) using LIBSSH2\_CALLBACK\_AUTHAGENT\_SIGN to sign an authentication challenge from a server. However, the client is responsible for implementing the code that calls this callback in response to a SSH2\_AGENTC\_SIGN\_REQUEST message.

## RETURN VALUE

Returns 0 if succeeded, or a negative value for error.

## AVAILABILITY

Added in libssh2 1.11.0

## SEE ALSO

**[libssh2\_agent\_init(3)](/libssh2_agent_init/3.md)** **[libssh2\_agent\_get\_identity(3)](/libssh2_agent_get_identity/3.md)** **[libssh2\_agent\_userauth(3)](/libssh2_agent_userauth/3.md)** **[libssh2\_session\_callback\_set2(3)](/libssh2_session_callback_set2/3.md)**
