libssh2_hostkey_hash(3)

πŸ“¦
version 1.11.1 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, epel 10, epel 9, fedora 43, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– libssh2_hostkey_hash β€” bestie, it's the hostkey hash page πŸ’–

okay so this is a page from the libssh2 manual (section 3, if you're keeping score), and it's literally all about grabbing a hash of the remote host's key. no cap. let's get into it ✨


🌸 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 β€” the session instance, and bestie you gotta get it from libssh2_session_init_ex(3) or it's not gonna work, iykyk 🫢
  • hash_type β€” pick your fighter, it's one of: LIBSSH2_HOSTKEY_HASH_MD5, LIBSSH2_HOSTKEY_HASH_SHA1 or LIBSSH2_HOSTKEY_HASH_SHA256.

So what does it actually do? It returns the computed digest of the remote system's hostkey. the way that the length of the returned string is hash_type specific… like, 16 bytes for MD5, 20 bytes for SHA1, 32 bytes for SHA256. slay πŸ’…


πŸ‘‘ RETURN VALUE πŸ‘‘

You get the computed hostkey hash value back, or NULL if the info is just not available β€” and that happens in two cases: either the session hasn't been started up yet, or the hash algorithm you asked for wasn't available. πŸ™ˆ

⚠️ real talk: the hash is made of raw binary bytes, not hex digits, so it is not directly printable. do not try to print it like a string, it will give you chaos πŸ’€

🌈 SEE ALSO 🌈

libssh2_session_init_ex(3)


kisses, bestie πŸ’– this was the libssh2 manual, version 0.15, dated 1 Jun 2007 β€” go hash that hostkey, you absolute icon πŸ‘‘βœ¨πŸŽ€