libssh2_knownhost_check(3)
π 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. π
hostis 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.keyis a pointer to the key for the given host.keylenis the total size in bytes of the key thatkeyis pointing at.typemaskis 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_PLAINLIBSSH2_KNOWNHOST_TYPE_CUSTOM
and the key is encoded using one of these encodings:
LIBSSH2_KNOWNHOST_KEYENC_RAWLIBSSH2_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. π«Άβ¨
π¦ 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