---
name: "libssh2_hostkey_hash"
section: "3"
platform: "linux"
package: "libssh2"
version: "1.11.1-7"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libssh2_hostkey_hash"
---

# libssh2\_hostkey\_hash(3)

return a hash of the remote host's key

## NAME

libssh2\_hostkey\_hash - return a hash of the remote host's key

## SYNOPSIS

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

## DESCRIPTION

*session* - Session instance as returned by **[libssh2\_session\_init\_ex(3)](/libssh2_session_init_ex/3.md)**

*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.

## SEE ALSO

**[libssh2\_session\_init\_ex(3)](/libssh2_session_init_ex/3.md)**
