libssh2_userauth_list(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– libssh2_userauth_list β€” the "so what can I even log in with??" function πŸ’–

okay bestie, welcome to libssh2_userauth_list(3), straight out of the libssh2 manual, section 3. this is the one you call when you wanna slide into a server's DMs and be like "hey… what auth methods are we even doing here πŸ‘€". no cap, it's giving recon but make it polite.


✨ NAME ✨

libssh2_userauth_list β€” list supported authentication methods 🌸


πŸŽ€ SYNOPSIS πŸŽ€

#include <libssh2.h>

char *
libssh2_userauth_list(LIBSSH2_SESSION *session,
                      const char *username,
                      unsigned int username_len);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so, the arguments, one by one, because we don't skip:

  • session β€” your Session instance, the one you got back from libssh2_session_init_ex(3). your whole vibe lives in there πŸ’…
  • username β€” the username that's gonna be used while authenticating. and listen, this part matters: most server implementations do not permit attempting authentication with different usernames between requests. so this has to be the same username you'll use on your later userauth calls. consistency is the moment, periodt.
  • username_len β€” the length of the username parameter. yes bestie, you gotta tell it how long your string is. it's that kind of API. πŸ™ˆ

now the actual plot: this function sends a SSH_USERAUTH_NONE request to the remote host. unless the remote host is configured to accept none as a viable authentication scheme (which, lol, unlikely), it'll come back with SSH_USERAUTH_FAILURE β€” and a listing of what authentication schemes it does support. that's the whole point, that's the tea β˜•

and in the unlikely event that none authentication actually succeeds?? this method will return NULL. 😭 which sounds identical to failing, BUT β€” and this is the iconique part β€” you can tell these two cases apart by examining libssh2_userauth_authenticated(3). so don't panic, just vibe check it.


⭐ RETURN VALUE ⭐

  • On success: a comma delimited list of supported authentication schemes. πŸŽ‰ this list is internally managed by libssh2, so like… it's not yours, don't free it, don't touch it, just admire it.
  • On failure: NULL. that's it. that's the whole return value. πŸ’€

πŸ’œ ERRORS πŸ’œ

  • LIBSSH2_ERROR_ALLOC β€” an internal memory allocation call failed. the malloc said "not today" πŸ˜”
  • LIBSSH2_ERROR_SOCKET_SEND β€” unable to send data on socket. the socket is ghosting you fr fr πŸ‘»
  • LIBSSH2_ERROR_EAGAIN β€” marked for non-blocking I/O but the call
bestie i am NOT making that up, that last line genuinely just stops mid-sentence in the source. i am reporting it exactly as it is, because the one rule is that the facts stay and only the vibe changes. 🫢

🌈 SEE ALSO 🌈


and that's the page!! slay πŸŽ€

this lil masterpiece comes to you from libssh2 0.15, dated 1 Jun 2007 β€” yeah she's vintage, she's iconic, she's been holding it down since before some of us could walk. drink water, read your error codes, and always check libssh2_userauth_authenticated(3) before you assume the worst πŸ’–πŸ’…βœ¨