Added a call to libssh2_knownhost_writefile()
Updated to the slightly modified libssh2_knownhost_check() proto
Этот коммит содержится в:
родитель
8cd76af353
Коммит
517909d37a
@ -133,23 +133,26 @@ int main(int argc, char *argv[])
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* read all hosts from here */
|
||||||
libssh2_knownhost_readfile(nh, "known_hosts",
|
libssh2_knownhost_readfile(nh, "known_hosts",
|
||||||
LIBSSH2_KNOWNHOST_FILE_OPENSSH);
|
LIBSSH2_KNOWNHOST_FILE_OPENSSH);
|
||||||
|
|
||||||
|
/* store all known hosts to here */
|
||||||
|
libssh2_knownhost_writefile(nh, "dumpfile",
|
||||||
|
LIBSSH2_KNOWNHOST_FILE_OPENSSH);
|
||||||
|
|
||||||
fingerprint = libssh2_session_hostkey(session, &len);
|
fingerprint = libssh2_session_hostkey(session, &len);
|
||||||
if(fingerprint) {
|
if(fingerprint) {
|
||||||
struct libssh2_knownhost host;
|
struct libssh2_knownhost *host;
|
||||||
int check;
|
int check = libssh2_knownhost_check(nh, (char *)hostname,
|
||||||
|
(char *)fingerprint, len,
|
||||||
check = libssh2_knownhost_check(nh, (char *)hostname,
|
LIBSSH2_KNOWNHOST_TYPE_PLAIN|
|
||||||
(char *)fingerprint, len,
|
LIBSSH2_KNOWNHOST_KEYENC_RAW,
|
||||||
LIBSSH2_KNOWNHOST_TYPE_PLAIN|
|
&host);
|
||||||
LIBSSH2_KNOWNHOST_KEYENC_RAW,
|
|
||||||
&host);
|
|
||||||
|
|
||||||
fprintf(stderr, "Host check: %d, key: %s\n", check,
|
fprintf(stderr, "Host check: %d, key: %s\n", check,
|
||||||
(check <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)?
|
(check <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)?
|
||||||
host.key:"<none>");
|
host->key:"<none>");
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
* At this point, we could verify that 'check' tells us the key is
|
* At this point, we could verify that 'check' tells us the key is
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user