libsshpp v0.1.7
Modern C++17 wrapper for libssh
Loading...
Searching...
No Matches
known_hosts.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2#pragma once
3
4#include <sshpp/config.hpp>
5
6#include <sshpp/export.hpp>
7#include <sshpp/key.hpp>
8#include <sshpp/result.hpp>
9
10#include <cstdint>
11#include <filesystem>
12#include <string>
13#include <string_view>
14#include <vector>
15
16namespace sshpp {
17
19
21 std::string hosts_field;
22 std::string marker;
25 std::string comment;
26 std::filesystem::path file;
27 int line = 0;
28};
29
32class SSHPP_API KnownHosts {
33public:
34 explicit KnownHosts(std::filesystem::path user_file, std::filesystem::path global_file = {});
35
36 static KnownHosts default_files();
37
38 Result<void> add(std::string_view host, std::uint16_t port, const Key&, std::string_view comment = {});
39
41 static Result<KnownHostsEntry> parse_line(std::string_view host, std::string_view line);
42
43private:
44 std::filesystem::path user_file_;
45 std::filesystem::path global_file_;
46};
47
48} // namespace sshpp
49
50#if SSHPP_HEADER_ONLY
52#endif
Definition key.hpp:59
Definition known_hosts.hpp:32
Definition result.hpp:16
Definition auth.hpp:18
KnownHostsStatus
Definition known_hosts.hpp:18
KeyType
Definition key.hpp:20
Definition known_hosts.hpp:20
std::string marker
Definition known_hosts.hpp:22
Key key
Definition known_hosts.hpp:24
std::string hosts_field
Definition known_hosts.hpp:21
KeyType key_type
Definition known_hosts.hpp:23
std::string comment
Definition known_hosts.hpp:25
std::filesystem::path file
Definition known_hosts.hpp:26
int line
Definition known_hosts.hpp:27