mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-05 20:55:47 +03:00
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.
This commit is contained in:
@@ -99,6 +99,18 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
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 */
|
/* check what authentication methods are available */
|
||||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||||
printf("Authentication methods: %s\n", userauthlist);
|
printf("Authentication methods: %s\n", userauthlist);
|
||||||
@@ -151,17 +163,7 @@ int main(int argc, char *argv[])
|
|||||||
goto shutdown;
|
goto shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* At this point we havn't authenticated. The first thing to do is check
|
/* We're authenticated now. */
|
||||||
* 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");
|
|
||||||
|
|
||||||
/* Request a shell */
|
/* Request a shell */
|
||||||
if (!(channel = libssh2_channel_open_session(session))) {
|
if (!(channel = libssh2_channel_open_session(session))) {
|
||||||
|
Reference in New Issue
Block a user