diff --git a/example/simple/ssh2_exec.c b/example/simple/ssh2_exec.c index 64ca644..20429d0 100644 --- a/example/simple/ssh2_exec.c +++ b/example/simple/ssh2_exec.c @@ -133,23 +133,26 @@ int main(int argc, char *argv[]) return 2; } + /* read all hosts from here */ libssh2_knownhost_readfile(nh, "known_hosts", 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); if(fingerprint) { - struct libssh2_knownhost host; - int check; - - check = libssh2_knownhost_check(nh, (char *)hostname, - (char *)fingerprint, len, - LIBSSH2_KNOWNHOST_TYPE_PLAIN| - LIBSSH2_KNOWNHOST_KEYENC_RAW, - &host); + struct libssh2_knownhost *host; + int check = libssh2_knownhost_check(nh, (char *)hostname, + (char *)fingerprint, len, + LIBSSH2_KNOWNHOST_TYPE_PLAIN| + LIBSSH2_KNOWNHOST_KEYENC_RAW, + &host); fprintf(stderr, "Host check: %d, key: %s\n", check, (check <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)? - host.key:""); + host->key:""); /***** * At this point, we could verify that 'check' tells us the key is