moved blocks to make keyboard-interactive second choice (if implemented).

This commit is contained in:
Guenter Knauf 2007-07-19 17:08:54 +00:00
parent 278219fc0a
commit 854dffe0a4

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ssh2.c,v 1.11 2007/07/19 15:43:48 gknauf Exp $ * $Id: ssh2.c,v 1.12 2007/07/19 17:08:54 gknauf Exp $
* *
* Sample showing how to do SSH2 connect. * Sample showing how to do SSH2 connect.
* *
@ -109,10 +109,10 @@ int main(int argc, char *argv[])
if (strstr(userauthlist, "password") != NULL) { if (strstr(userauthlist, "password") != NULL) {
auth_pw |= 1; auth_pw |= 1;
} }
if (strstr(userauthlist, "publickey") != NULL) { if (strstr(userauthlist, "keyboard-interactive") != NULL) {
auth_pw |= 2; auth_pw |= 2;
} }
if (strstr(userauthlist, "keyboard-interactive") != NULL) { if (strstr(userauthlist, "publickey") != NULL) {
auth_pw |= 4; auth_pw |= 4;
} }
@ -124,7 +124,17 @@ int main(int argc, char *argv[])
} else { } else {
printf("\tAuthentication by password succeeded.\n"); printf("\tAuthentication by password succeeded.\n");
} }
#if 0 /* !! not implemented yet !! */
} else if (auth_pw & 2) { } else if (auth_pw & 2) {
/* Or via keyboard-interactive */
if (libssh2_userauth_keyboard_interactive(session, username, response_callback) ) {
printf("\tAuthentication by keyboard-interactive failed!\n");
goto shutdown;
} else {
printf("\tAuthentication by keyboard-interactive succeeded.\n");
}
#endif
} else if (auth_pw & 4) {
/* Or by public key */ /* Or by public key */
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1, keyfile2, password)) { if (libssh2_userauth_publickey_fromfile(session, username, keyfile1, keyfile2, password)) {
printf("\tAuthentication by public key failed!\n"); printf("\tAuthentication by public key failed!\n");
@ -132,16 +142,6 @@ int main(int argc, char *argv[])
} else { } else {
printf("\tAuthentication by public key succeeded.\n"); printf("\tAuthentication by public key succeeded.\n");
} }
#if 0 /* !! not implemented yet !! */
} else if (auth_pw & 4) {
/* Or via keyboard-interactive */
if (libssh2_userauth_keyboard_interactive(session, username, getpw_callback) ) {
printf("\tAuthentication by keyboard-interactive failed!\n");
goto shutdown;
} else {
printf("\tAuthentication by keyboard-interactive succeeded.\n");
}
#endif
} else { } else {
printf("No supported authentication methods found!\n"); printf("No supported authentication methods found!\n");
goto shutdown; goto shutdown;