libssh2_session_methods(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_session_methods β€” bestie, let's find out which algorithms are ACTUALLY running πŸ’…

ok so real talk: this is the libssh2 function that tells you which algorithms your session ended up using. Like, you asked for a whole menu of options and SSH picked one β€” this is how you find out which one. Iconic behaviour fr fr. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <libssh2.h>

const char *
libssh2_session_methods(LIBSSH2_SESSION *session, int method_type);

πŸ’– DESCRIPTION πŸ’–

So you pass in two things, bestie:

  • session β€” the session instance, aka the thing you got back from libssh2_session_init_ex(3). You know her. πŸ‘‘
  • method_type β€” literally just one of these method type constants, pick your fighter:
    • LIBSSH2_METHOD_KEX
    • LIBSSH2_METHOD_HOSTKEY
    • LIBSSH2_METHOD_CRYPT_CS
    • LIBSSH2_METHOD_CRYPT_SC
    • LIBSSH2_METHOD_MAC_CS
    • LIBSSH2_METHOD_MAC_SC
    • LIBSSH2_METHOD_COMP_CS
    • LIBSSH2_METHOD_COMP_SC
    • LIBSSH2_METHOD_LANG_CS
    • LIBSSH2_METHOD_LANG_SC
    • LIBSSH2_METHOD_SIGN_ALGO

And what does it do?? It returns the actual method negotiated for that particular transport parameter. Not the list you offered. Not the list they offered. The one that actually got picked. The main character. 🌟


πŸŽ€ RETURN VALUE πŸŽ€

You get the negotiated method back as a string. πŸ’«

But β€” and this is the plot twist β€” you get NULL if the session has not yet been started. Like, girl hasn't even shown up to the party yet, there's nothing to report. 😭


πŸ’€ ERRORS πŸ’€

  • LIBSSH2_ERROR_INVAL β€” the requested method type was invalid. You handed it a constant that doesn't exist, bestie, that's on you. πŸ™ˆ
  • LIBSSH2_ERROR_METHOD_NONE β€” no method has been set. Empty. Void. Nothing there. πŸ’€

🌈 SEE ALSO 🌈


and that's the whole vibe check, babe β€” go forth and inspect your transport parameters, you absolute legend 🫢✨

mwah πŸ’‹ this page lives in libssh2 1.11, dated 8 Nov 2021, and it's part of the libssh2 manual β€” now go slay some SSH πŸ’…πŸ‘‘