1
1

example/ssh2_agent: Print host key fingerprint before authentication

Also moves the comment about not being authenticated to before the
agent authentication takes place, so that it better matches the code.
Этот коммит содержится в:
Peter Stuge 2011-10-05 16:55:58 +02:00
родитель ee07785a1e
Коммит c292378327

Просмотреть файл

@ -99,6 +99,18 @@ int main(int argc, char *argv[])
return 1;
}
/* At this point we havn't authenticated. The first thing to do is check
* the hostkey's fingerprint against our known hosts Your app may have it
* hard coded, may go to a file, may present it to the user, that's your
* call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
printf("Fingerprint: ");
for(i = 0; i < 20; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
/* check what authentication methods are available */
userauthlist = libssh2_userauth_list(session, username, strlen(username));
printf("Authentication methods: %s\n", userauthlist);
@ -151,17 +163,7 @@ int main(int argc, char *argv[])
goto shutdown;
}
/* At this point we havn't authenticated. The first thing to do is check
* the hostkey's fingerprint against our known hosts Your app may have it
* hard coded, may go to a file, may present it to the user, that's your
* call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
printf("Fingerprint: ");
for(i = 0; i < 20; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
/* We're authenticated now. */
/* Request a shell */
if (!(channel = libssh2_channel_open_session(session))) {