this way we can get ssh error message if connection setup fails. Change-Id: Ifc001f77ec0477fb9786f7767a47f3745d6475ff
50 lines
913 B
C++
50 lines
913 B
C++
#pragma once
|
|
///@file
|
|
|
|
#include "lix/libutil/file-system.hh"
|
|
#include "lix/libutil/processes.hh"
|
|
#include "lix/libutil/sync.hh"
|
|
#include <cstdint>
|
|
|
|
namespace nix {
|
|
|
|
class SSH
|
|
{
|
|
private:
|
|
|
|
const std::string host;
|
|
const std::optional<uint16_t> port;
|
|
bool fakeSSH;
|
|
const std::string keyFile;
|
|
const std::string sshPublicHostKey;
|
|
const bool compress;
|
|
const int logFD;
|
|
|
|
struct State
|
|
{
|
|
std::unique_ptr<AutoDelete> tmpDir;
|
|
};
|
|
|
|
Sync<State> state_;
|
|
|
|
void addCommonSSHOpts(Strings & args);
|
|
|
|
public:
|
|
SSH(const std::string & host,
|
|
const std::optional<uint16_t> port,
|
|
const std::string & keyFile,
|
|
const std::string & sshPublicHostKey,
|
|
bool compress,
|
|
int logFD);
|
|
|
|
struct Connection
|
|
{
|
|
Pid sshPid;
|
|
AutoCloseFD socket;
|
|
};
|
|
|
|
std::unique_ptr<Connection> startCommand(const std::string & command);
|
|
};
|
|
|
|
}
|