18#pragma GCC diagnostic push
19#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
24#include <libssh/libssh.h>
25#include <libssh/server.h>
31namespace svcs::server::ssh {
59 using CommandHandler = std::function<bool(
const std::string&, ssh_channel)>;
74 SSHSession(ssh_session session,
75 const SSHConfig& config,
76 CommandHandler handler);
88 SSHSession(
const SSHSession&) =
delete;
89 SSHSession& operator=(
const SSHSession&) =
delete;
92 SSHSession(SSHSession&& other)
noexcept;
93 SSHSession& operator=(SSHSession&& other)
noexcept;
115 bool isAlive()
const;
126 std::string getUsername()
const {
return username_; }
137 std::string getClientIp()
const;
148 std::chrono::system_clock::time_point getStartTime()
const {
return start_time_; }
161 bool handleCommand();
162 bool validatePublicKey(ssh_key key);
163 bool validatePassword(
const std::string& username,
const std::string& password);
164 std::vector<std::string> loadAuthorizedKeys(
const std::string& username)
const;
165 std::string getPasswordHash(
const std::string& username)
const;
168 ssh_session session_;
170 CommandHandler handler_;
171 std::string username_;
172 bool authenticated_ =
false;
173 std::chrono::system_clock::time_point start_time_;
174 bool owns_session_ =
true;
180#pragma GCC diagnostic pop
Cross-platform network utilities.
SSH server configuration.