class SshHosts
This class encapsulates a list of known hosts which can be used to verify the identity of a remote ssh server, and provides methods for managing the list. Currently only OpenSSH known hosts file format is supported.
bool Add(const String& host, const SshHosts::Info& info, const String& comment)
bool Add(const String& host, int port, const SshHosts::Info& info, const String& comment)
Adds a host to the known hosts list. Usually after verification. Returns true on success.
bool Remove(SshHost* host)
Removes a host from the known hosts list. Returns true on success.
bool Load(const String& filename)
Loads a list of known hosts from a specified file and adds them to the list of known hosts. Returns true on success.
bool Save()
Saves the list of known host to a previously loaded file. Returns true on success. .
bool SaveAs(const String& filename)
Saves the list of known hosts to another file. Returns true on success.
SshHosts::Info Check(const String& host, int port)
Checks a host and its key against a list of known hosts. Returns a SshHosts::Info structure.
Vector<SshHost*> GetHosts()
Returns a list of known hosts. Note that an empty list doesn't necessarily mean error.
int GetError() const
Returns the last error code.
String GetErrorDesc() const
Returns the decription of last error.
SshHosts(SshSession& session)
Constructor. Binds the SshHosts instance to session.
struct Info
This helper structure is intended to simplify known host queries.
String key
Public key of the given host.
bool IsRSA() const
Returns true if the public key of the given host is using RSA algorithm.
bool IsDSS() const
Returns true if the public key of the given host is using DSS algorithm.
bool IsECDSA256() const
Returns true if the public key of the given host is using ECDSA 256 algorithm.
bool IsECDSA384() const
Returns true if the public key of the given host is using ECDSA 384 algorithm.
bool IsECDSA521() const
Returns true if the public key of the given host is using ECDSA 521 algorithm.
bool IsED25519() const
Returns true if the public key of the given host is using ED 25519 algorithm.
bool IsUnknown() const
Returns true if the public key of the given host is of unknown type.
bool IsFailure() const
Returns true if something prevented the check to be made.
bool IsNotFound() const
Returns true if no host match was found.
bool IsMismatch() const
Returns true if the host was found, but the keys didn't match. (This may mean an attack!)
bool IsMatch() const
Returns true if the hosts and the keys match.
|