few cosmetic changes; added block for future implementation of keyboard-interactive method.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: ssh2.c,v 1.10 2007/07/19 15:29:06 gknauf Exp $
|
* $Id: ssh2.c,v 1.11 2007/07/19 15:43:48 gknauf Exp $
|
||||||
*
|
*
|
||||||
* Sample showing how to do SSH2 connect.
|
* Sample showing how to do SSH2 connect.
|
||||||
*
|
*
|
||||||
@@ -119,19 +119,29 @@ int main(int argc, char *argv[])
|
|||||||
if (auth_pw & 1) {
|
if (auth_pw & 1) {
|
||||||
/* We could authenticate via password */
|
/* We could authenticate via password */
|
||||||
if (libssh2_userauth_password(session, username, password)) {
|
if (libssh2_userauth_password(session, username, password)) {
|
||||||
printf("Authentication by password failed.\n");
|
printf("\tAuthentication by password failed!\n");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
} else {
|
} else {
|
||||||
printf("Authentication by password succeeded.\n");
|
printf("\tAuthentication by password succeeded.\n");
|
||||||
}
|
}
|
||||||
} else if (auth_pw & 2) {
|
} else if (auth_pw & 2) {
|
||||||
/* 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");
|
||||||
goto shutdown;
|
goto shutdown;
|
||||||
} else {
|
} else {
|
||||||
printf("Authentication 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;
|
||||||
|
Reference in New Issue
Block a user