libssh2_hostkey_hash(3)

libssh2_hostkey_hash3

Return a hash of the remote host's key

Usage

#include <libssh2.h>
const char *
libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type);

Overview

session - Session instance as returned by libssh2_session_init_ex(3)

hash_type - One of: LIBSSH2_HOSTKEY_HASH_MD5, LIBSSH2_HOSTKEY_HASH_SHA1 or LIBSSH2_HOSTKEY_HASH_SHA256.

Returns the computed digest of the remote system's hostkey. The length of the returned string is hash_type specific (e.g. 16 bytes for MD5, 20 bytes for SHA1, 32 bytes for SHA256).

Return value

Computed hostkey hash value, or NULL if the information is not available (either the session has not yet been started up, or the requested hash algorithm was not available). The hash consists of raw binary bytes, not hex digits, so it is not directly printable.

Releases

10 releases since Debian 5.0 (Lenny); the text changed 5 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8–10
  5. 11–12
  6. 13–Arch

From libssh2 1.11.1-7 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.