Go to main content

man pages section 3: Extended Library Functions, Volume 1

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

libssh2_knownhost_check (3ssh2)

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

libssh2 manual                                  libssh2_knownhost_check(3ssh2)



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
       Checks a host and its associated key against the  collection  of  known
       hosts, and returns info back about the (partially) matched entry.

       host is a pointer the host name in plain text. The host name can be the
       IP numerical address of the host or the full name.

       key is a pointer to the key for the given host.

       keylen is the total size in bytes of the key  pointed  to  by  the  key
       argument

       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  is given as one of the following types: LIBSSH2_KNOWN-
       HOST_TYPE_PLAIN or LIBSSH2_KNOWNHOST_TYPE_CUSTOM.

       The key is encoded using one of the following encodings: LIBSSH2_KNOWN-
       HOST_KEYENC_RAW or LIBSSH2_KNOWNHOST_KEYENC_BASE64.

       knownhost  if  set  to non-NULL, it must be a pointer to a 'struct lib-
       ssh2_knownhost' pointer that gets filled in to point to  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  to  be
       made

       LIBSSH2_KNOWNHOST_CHECK_NOTFOUND - no host match was found

       LIBSSH2_KNOWNHOST_CHECK_MATCH - hosts and keys match.

       LIBSSH2_KNOWNHOST_CHECK_MISMATCH  - host was found, but the keys didn't
       match!

AVAILABILITY
       Added in libssh2 1.2

EXAMPLE
       See the ssh2_exec.c example as provided in the tarball.


ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       +---------------+------------------+
       |ATTRIBUTE TYPE | ATTRIBUTE VALUE  |
       +---------------+------------------+
       |Availability   | library/libssh2  |
       +---------------+------------------+
       |Stability      | Uncommitted      |
       +---------------+------------------+

SEE ALSO
       libssh2_knownhost_init(3)   libssh2_knownhost_free(3)    libssh2_known-
       host_add(3)



NOTES
       Source  code  for open source software components in Oracle Solaris can
       be found at https://www.oracle.com/downloads/opensource/solaris-source-
       code-downloads.html.

       This     software     was    built    from    source    available    at
       https://github.com/oracle/solaris-userland.   The  original   community
       source   was   downloaded  from   https://www.libssh2.org/download/lib-
       ssh2-1.10.0.tar.gz.

       Further information about this software can be found on the open source
       community website at https://www.libssh2.org/.



libssh2 1.2                       28 May 2009
                                                libssh2_knownhost_check(3ssh2)