libssh2_knownhost_add(3)
π 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 uselibssh2_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,salthas 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 thekeyargument. 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_PLAINLIBSSH2_KNOWNHOST_TYPE_SHA1LIBSSH2_KNOWNHOST_TYPE_CUSTOM
The key is encoded using one of the following encodings:
LIBSSH2_KNOWNHOST_KEYENC_RAWLIBSSH2_KNOWNHOST_KEYENC_BASE64
The key is using one of these algorithms:
LIBSSH2_KNOWNHOST_KEY_RSA1LIBSSH2_KNOWNHOST_KEY_SSHRSALIBSSH2_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.NULLcan 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 π
libssh2_knownhost_init(3)libssh2_knownhost_free(3)libssh2_knownhost_check(3)libssh2_knownhost_addc(3)
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 π
β¨π
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms