libssh2_knownhost_add(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_knownhost_add β€” adding a known host, the old way ✨

okay bestie, so this one lives in the libssh2 manual, section 3, and it's called libssh2_knownhost_add. Let's get into it 🫢


🌸 NAME 🌸

libssh2_knownhost_add β€” add a known host πŸ’…


✨ SYNOPSIS ✨

#include <libssh2.h>

int
libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
                      char *host, char *salt,
                      char *key, size_t keylen,
                      int typemask,
                      struct libssh2_knownhost **store);

πŸŽ€ DESCRIPTION πŸŽ€

🚨 bestie, heads up, this is the important part: we discourage use of this function as of libssh2 1.2.5. Instead we strongly urge users to use libssh2_knownhost_addc(3) instead, which is a more complete API. libssh2_knownhost_add(3) is subject for removal in a future release. so like… it's giving "legacy", and not in a cute way 😭

Okay so what does it actually do? It adds a known host to the collection of known hosts identified by the hosts handle. Simple as that. 🌟

  • host β€” a pointer to the host name, in plain text or hashed. If it's hashed, it must be provided base64 encoded. The host name can be the IP numerical address of the host or the full name. either one, we don't gatekeep πŸ’«
  • saltP β€” a pointer to the salt used for the host hashing, if the host is provided hashed. If the host is provided in plain text, salt has no meaning. The salt has to be provided base64 encoded with a trailing zero byte. don't forget the trailing zero byte, that's the whole vibe check πŸ™ˆ
  • key β€” a pointer to the key for the given host. πŸ”‘
  • keylen β€” the total size in bytes of the key pointed to by the key argument. count every byte, no rounding, no vibes-based math πŸ’…
  • typemask β€” 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. it's basically the whole personality of your call ✨

The host name is given as one of the following types:

  • LIBSSH2_KNOWNHOST_TYPE_PLAIN
  • LIBSSH2_KNOWNHOST_TYPE_SHA1
  • LIBSSH2_KNOWNHOST_TYPE_CUSTOM

The key is encoded using one of the following encodings:

  • LIBSSH2_KNOWNHOST_KEYENC_RAW
  • LIBSSH2_KNOWNHOST_KEYENC_BASE64

The key is using one of these algorithms:

  • LIBSSH2_KNOWNHOST_KEY_RSA1
  • LIBSSH2_KNOWNHOST_KEY_SSHRSA
  • LIBSSH2_KNOWNHOST_KEY_SSHDSS β€” deprecated, so like, it's on its way out, tread carefully πŸ’€
  • store β€” should point to a pointer that gets filled in to point to the known host data after the addition. NULL can be passed if you do not care about this pointer. no thoughts, head empty, totally valid πŸ“

πŸ”₯ RETURN VALUE πŸ”₯

Returns a regular libssh2 error code, where negative values are error codes and 0 indicates success. so if you get a 0, that's a slay. anything negative? that's a "not me" moment 😭


🌈 AVAILABILITY 🌈

Added in libssh2 1.2, deprecated since libssh2 1.2.5. Use libssh2_knownhost_addc(3) instead! like fr fr, go use the other one 🫢


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie πŸ’– this one came from the libssh2 manual, dated 28 May 2009, and it's the libssh2_knownhost_add(3) page β€” go forth and use libssh2_knownhost_addc(3) instead, periodt πŸ’…βœ¨πŸŽ€