libssh2_knownhost_check(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_knownhost_check(3) πŸ’–

okay bestie, so this one lives in the libssh2 manual, and it's literally called libssh2_knownhost_check. yes we're doing host-key detective work today. grab a strawberry πŸ“ and let's go.


✨ NAME ✨

libssh2_knownhost_check β€” check a host+key against the list of known hosts πŸ‘€


🌸 SYNOPSIS 🌸

#include <libssh2.h>

int
libssh2_knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
                        const char *host,
                        const char *key, size_t keylen,
                        int typemask,
                        struct libssh2_knownhost **knownhost);

πŸ¦‹ DESCRIPTION πŸ¦‹

So what this does is: it takes a host and its key, holds them up against your whole collection of known hosts, and reports back what it found about the (partially) matched entry. it's giving vibe check, but for host keys. πŸ’…

  • host is a pointer to the host name in plain text. and like, it can be the IP numerical address of the host or the full name, both are valid, she's flexible like that.
  • key is a pointer to the key for the given host.
  • keylen is the total size in bytes of the key that key is pointing at.
  • typemask is a bitmask that specifies format and info about the data passed to this function. specifically, it details what format the host name is, what format the key is, and what key type it is.

the host name gets given as one of these types, ok:

  • LIBSSH2_KNOWNHOST_TYPE_PLAIN
  • LIBSSH2_KNOWNHOST_TYPE_CUSTOM

and the key is encoded using one of these encodings:

  • LIBSSH2_KNOWNHOST_KEYENC_RAW
  • LIBSSH2_KNOWNHOST_KEYENC_BASE64

lastly, knownhost β€” if you set it to non-NULL, it has to be a pointer to a 'struct libssh2_knownhost' pointer, and that thing gets filled in so it points at info about a known host that matches or partially matches. no cap, that's the little output mailbox right there πŸ“¬


πŸ‘‘ RETURN VALUE πŸ‘‘

libssh2_knownhost_check(3) returns info about how well the provided host + key pair matched one of the entries in the list of known hosts. so like, a report card. a match report card. πŸŽ€

  • LIBSSH2_KNOWNHOST_CHECK_FAILURE β€” something prevented the check to be made 😭
  • LIBSSH2_KNOWNHOST_CHECK_NOTFOUND β€” no host match was found πŸ«₯
  • LIBSSH2_KNOWNHOST_CHECK_MATCH β€” hosts and keys match. slay!! βœ…
  • LIBSSH2_KNOWNHOST_CHECK_MISMATCH β€” host was found, but the keys did not match! 🚨
not the mismatch 😭 that one is the "who ARE you" of return values, okay. respect it.

🌈 AVAILABILITY 🌈

Added in libssh2 1.2 ⭐


🧚 EXAMPLE 🧚

See the ssh2_exec.c example as provided in the tarball. go peek, it's right there πŸ“‚


πŸ’œ SEE ALSO πŸ’œ


and that's the whole page bestie, ily, go check those hosts πŸ’–

libssh2 Β· 28 May 2009 Β· libssh2_knownhost_check(3) β€” mwah, that's the version and the date, periodt. 🫢✨