libssh2_knownhost_readfile(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_readfile β€” bestie, it's time to read your known_hosts file

okay so picture this: you're in the libssh2 manual (yes we're in section 3, the library-call section, iykyk) and you found libssh2_knownhost_readfile(3). it's giving "load up all my lil known hosts from a file." let's get into it πŸ¦‹


✨ SYNOPSIS ✨

#include <libssh2.h>

int
libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
                           const char *filename, int type);

🌸 DESCRIPTION 🌸

so basically this function reads a whole collection of known hosts out of a file you point it at, and then adds them to the collection of known hosts you already have. it's literally just scooping them in. no drama, no cap. πŸ’…

  • filename β€” this is the one that specifies which file to read. that's it. that's the whole job. point at the file, bestie 🫢
  • type β€” this tells it what file type it is. and rn, LIBSSH2_KNOWNHOST_FILE_OPENSSH is the only currently supported format. this file is normally found hanging out named ~/.ssh/known_hosts β€” yeah, that one. the iconic one. πŸ‘‘

⭐ RETURN VALUE ⭐

here's the vibe check on what you get back:

  • a negative value β€” that's your regular libssh2 error code, so something went wrong 😭
  • a positive number β€” that's the number of parsed known hosts in the file, and that's a slay ✨

🌈 AVAILABILITY 🌈

added in libssh2 1.2 β€” so she's been around a minute, a real veteran πŸ’œ


πŸŽ€ SEE ALSO πŸŽ€

go read these next, fr fr:


and that's the whole page, bestie 🧚 this lil slice of the libssh2 manual (yes, manual name is literally libssh2) was dated 28 May 2009 and shipped under the source/version tag libssh2 β€” so go forth, read those hosts, and stay iconic πŸ’–πŸŒΈπŸ’