libssh2_knownhost_checkp(3)
π NAME π
libssh2_knownhost_checkp β bestie, this is the one that checks a host plus its key against your whole list of known hosts π«Ά
β¨ SYNOPSIS β¨
#include <libssh2.h>
int
libssh2_knownhost_checkp(LIBSSH2_KNOWNHOSTS *hosts,
const char *host, int port,
const char *key, size_t keylen,
int typemask,
struct libssh2_knownhost **knownhost);
πΈ DESCRIPTION πΈ
okay so this function takes a host and its key and holds them up against your entire collection of known hosts, then reports back the tea about the entry that matched (or partially matched). vibe check for host keys, basically π
hostβ pointer to the host name, in plain text. and like, it can be the IP numerical address of the host or the full name. either one, she's flexible β¨portβ the port number used by the host. (or a negative number if you wanna check the generic host instead.) and here's the thing: if you do give the port number,libssh2will check the key for that specific host + port number combo in addition to the plain host name only check. so you get both, lucky you πkeyβ pointer to the key for the given host πkeylenβ total size in bytes of the key that thekeyargument is pointing attypemaskβ a bitmask that spells out the format and info about the data you're passing in here. specifically: what format the host name is in, what format the key is in, and what key type it is π
the host name gets given as one of these types:
LIBSSH2_KNOWNHOST_TYPE_PLAINLIBSSH2_KNOWNHOST_TYPE_CUSTOM
and the key is encoded using one of these encodings:
LIBSSH2_KNOWNHOST_KEYENC_RAWLIBSSH2_KNOWNHOST_KEYENC_BASE64knownhostβ if you set this to non-NULL, it has to be a pointer to astruct libssh2_knownhostpointer. that thing gets filled in so it points at info about a known host that matches, or partially matches π¦
β 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.
LIBSSH2_KNOWNHOST_CHECK_FAILUREβ something prevented the check from being made πLIBSSH2_KNOWNHOST_CHECK_NOTFOUNDβ no host match was found πLIBSSH2_KNOWNHOST_CHECK_MATCHβ hosts and keys match π slayLIBSSH2_KNOWNHOST_CHECK_MISMATCHβ the host was found, but the keys did not match! π
not me about to be dramatic but that last one is genuinely the scary one. host showed up, key said "who r u". be careful bestie.
π AVAILABILITY π
added in libssh2 1.2.6 β so if you're on something older, it's giving β¨nothingβ¨
π EXAMPLE π
see the ssh2_exec.c example as provided in the tarball π¦
π SEE ALSO π
and that's the whole page, bestie π this one's from the libssh2 manual, dated 1 May 2010 β old but iconic, no cap. go check those host keys π«Ά
π¦ 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