1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00
Files
libssh2/docs/libssh2_knownhost_add.md
Viktor Szakats 967a24b3bb tidy-up: miscellaneous
- wincng: add version comments.
  Follow-up to 7a26697ede #397
- wincng: fix two version support comments.
- tests/keys-generate.sh: add comment, newlines.
- mbedtls: casing in comment.
- wording: use `null-terminator` more.
- typos: `ssh-dss`.
- knownhost: drop obsolete comment.
- include/libssh2.h: clarify comments.
- include/libssh2.h: drop empty lines.
- libssh2_knownhost_writeline.md: fix grammar.
- GHA: reorder Cygwin settings, improve package search URL.
- fixup newlines.

Closes #2617
2026-09-13 16:12:32 +02:00

2.6 KiB

c, SPDX-License-Identifier, Title, Section, Source, See-also
c SPDX-License-Identifier Title Section Source See-also
Copyright (C) Daniel Stenberg BSD-3-Clause libssh2_knownhost_add 3 libssh2
libssh2_knownhost_addc(3)
libssh2_knownhost_check(3)
libssh2_knownhost_free(3)
libssh2_knownhost_init(3)

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

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 as a more complete API. libssh2_knownhost_add(3) is subject for removal in a future release.

Adds a known host to the collection of known hosts identified by the 'hosts' handle.

host is a pointer the hostname in plain text or hashed. If hashed, it must be provided base64 encoded. The hostname can be the IP numerical address of the host or the full name.

*saltP is 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 null-terminator.

key is a pointer to the key for the given host.

keylen is the total size in bytes of the key pointed to by the key argument

typemask is a bitmask that specifies format and info about the data passed to this function. Specifically, it details what format the hostname is, what format the key is and what key type it is.

The hostname is given as one of the following types: LIBSSH2_KNOWNHOST_TYPE_PLAIN, LIBSSH2_KNOWNHOST_TYPE_SHA1 or LIBSSH2_KNOWNHOST_TYPE_CUSTOM.

The key is encoded using one of the following encodings: LIBSSH2_KNOWNHOST_KEYENC_RAW or 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), LIBSSH2_KNOWNHOST_KEY_ECDSA_256, LIBSSH2_KNOWNHOST_KEY_ECDSA_384, LIBSSH2_KNOWNHOST_KEY_ECDSA_521 or LIBSSH2_KNOWNHOST_KEY_ED25519.

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.

RETURN VALUE

Returns a regular libssh2 error code, where negative values are error codes and 0 indicates success.

AVAILABILITY

Added in libssh2 1.2, deprecated since libssh2 1.2.5. Use libssh2_knownhost_addc(3) instead!