libssh2_userauth_password_ex(3)
π libssh2_userauth_password_ex β bestie's guide π
okay so this is a page from the libssh2 manual, and today we're learning libssh2_userauth_password_ex β the glow-up version of "let me in, I have a password." π«Ά
β¨ NAME β¨
libssh2_userauth_password_ex β authenticate a session with username and password
πΈ SYNOPSIS πΈ
#include <libssh2.h>
int
libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
const char *username,
unsigned int username_len,
const char *password,
unsigned int password_len,
LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)));
#define libssh2_userauth_password(session, username, password) \
libssh2_userauth_password_ex((session), (username), \
strlen(username), \
(password), strlen(password), NULL)
two for the price of one, bestie β the big girl function and the lil macro wrapper that calls it for you. π
π¦ DESCRIPTION π¦
here's the whole cast, one by one:
sessionβ the session instance, as returned bylibssh2_session_init_ex(3). your main character. πusernameβ name of the user to attempt plain password authentication for. who are we pretending to be today.username_lenβ length of theusernameparameter. yes she wants the length separately, don't ask, it's a vibe.passwordβ the password used to authenticateusername. the secret. the tea. πpassword_lenβ length of thepasswordparameter.passwd_change_cbβ if the host accepts the authentication but requests that the password be changed, this callback will be issued. and like, if no callback is defined but the server required a password change, the authentication will fail. no callback, no entry, periodt. π
so what does it actually do? attempt basic password authentication. that's the whole job.
β οΈ lowkey important: many SSH servers which appear to support ordinary password authentication actually have it disabled and use Keyboard Interactive authentication instead β routed via PAM or another authentication backend. so if your password auth is mysteriously not working, it might not be you, it might be the server being sneaky. π
π RETURN VALUE π
returns 0 on success, or negative on failure. it returns LIBSSH2_ERROR_EAGAIN when it would otherwise block.
and the iconic caveat: while LIBSSH2_ERROR_EAGAIN is a negative number, it is not really a failure per se. it's just saying "not right now babe, come back later." β¨
π₯ ERRORS π₯
some of the errors this function may return include:
LIBSSH2_ERROR_ALLOCβ an internal memory allocation call failed. the malloc said no. πLIBSSH2_ERROR_SOCKET_SENDβ unable to send data on socket. the socket is not picking up the phone. π΅LIBSSH2_ERROR_PASSWORD_EXPIREDβ β¦and that's literally it, that's the whole description, the manual leaves it at that, no elaboration, slay I guess. πLIBSSH2_ERROR_AUTHENTICATION_FAILEDβ failed, invalid username/password or public/private key. the classic. the icon. the "who even are you." π«
π SEE ALSO π
and that's the whole page bestie, we ate, no crumbs left. this was the libssh2_userauth_password_ex(3) page from the libssh2 manual, version 0.15, dated 1 Jun 2007. iykyk πβ¨ππ¦
π¦ 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