---
name: "libssh2_session_hostkey"
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_session_hostkey"
---

# libssh2\_session\_hostkey(3)

get the remote key

## NAME

libssh2\_session\_hostkey - get the remote key

## SYNOPSIS

```
#include <libssh2.h>
const char *
libssh2_session_hostkey(LIBSSH2_SESSION *session,
                        size_t *len, int *type);
```

## DESCRIPTION

Returns a pointer to the current host key, the value *len* points to will get the length of the key.

The value *type* points to the type of hostkey which is one of: LIBSSH2\_HOSTKEY\_TYPE\_RSA, LIBSSH2\_HOSTKEY\_TYPE\_DSS (deprecated), or LIBSSH2\_HOSTKEY\_TYPE\_UNKNOWN.

## RETURN VALUE

A pointer, or NULL if something went wrong.

## SEE ALSO

**[libssh2\_knownhost\_check(3)](/libssh2_knownhost_check/3.md)** **[libssh2\_knownhost\_add(3)](/libssh2_knownhost_add/3.md)**
