libssh2_agent_sign(3)
β¨ libssh2_agent_sign β signing data with a lil help from your bestie ssh-agent β¨
okay so real talk, this one lives in the libssh2 manual (that's the manual name, bestie, remember it π
), and it's the page all about libssh2_agent_sign, aka letting your ssh-agent do the signing for you. no cap.
π 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);
look at her. eight arguments. she's that girl and she knows it. π
πΈ DESCRIPTION πΈ
okay bestie, let's go through the parameters one by one because there are a lot of them and each one matters, fr fr:
agentβ the ssh-agent handle, as returned bylibssh2_agent_init(3). it's giving "your agent, your rules". π«Άidentityβ the public key you're authenticating with, as returned bylibssh2_agent_get_identity(3). the whole main character of the auth story. πsigβ a pointer to a buffer where the signature gets placed. IMPORTANT: you, the caller, are responsible for freeing that signature withLIBSSH2_FREE. not optional. don't leak, bestie, it's not cute. πs_lenβ a pointer to the length of thesigparameter. she tells you how long the signature actually is. πdataβ the data to sign. the actual goods. β¨d_lenβ the length of thedataparameter. β¨methodβ a buffer indicating the signing method. and here's the vibe check: it should match the string at the start ofidentity->blob. like, they gotta match, okay? π§method_lenβ the length of themethodparameter. π
so what does the function actually do? it signs data using an ssh-agent. iconic behaviour honestly.
and the fun part: you can use this inside a callback registered with libssh2_session_callback_set2(3) using LIBSSH2_CALLBACK_AUTHAGENT_SIGN, to sign an authentication challenge coming from a server. slay. BUT β and this is the part people skip and then get confused β the client is responsible for implementing the code that calls this callback in response to a SSH2_AGENTC_SIGN_REQUEST message. so like, libssh2 sets up the callback slot, but you're the one wiring up the actual "hey, a sign request came in, let's go" logic. no one's doing that part for you, babe. π
π RETURN VALUE π
- returns
0if it succeeded π - or a negative value for error π
that's it. that's the whole vibe. 0 = good, negative = not good.
π¦ AVAILABILITY π¦
added in libssh2 1.11.0. so if you're on something older, she is simply not there yet, sorry babe. π
β SEE ALSO β
libssh2_agent_init(3)libssh2_agent_get_identity(3)libssh2_agent_userauth(3)libssh2_session_callback_set2(3)
go read them, they're the supporting cast and honestly they ate. π
and that's the whole page, bestie π β this one's from libssh2, dated 1 Oct 2022, and that's your sign-off. go forth and sign responsibly, and remember: free your sig with LIBSSH2_FREE or the memory leak is on you. periodt. πβ¨π¦
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms