[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
need help about how to use ssh_userauth_autopubkey
[Thread Prev] | [Thread Next]
- Subject: need help about how to use ssh_userauth_autopubkey
- From: "Linny.liang 梁玉林" <ylliang@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 8 Feb 2012 11:21:23 +0800
- To: "libssh" <libssh@xxxxxxxxxx>
do { message=ssh_message_get(session); if(!message) break; switch(ssh_message_type(message)){ case SSH_REQUEST_AUTH: switch(ssh_message_subtype(message)){ case SSH_AUTH_METHOD_PASSWORD: printf("ssh log: User %s wants to connect with pass %s\n", ssh_message_auth_user(message), ssh_message_auth_password(message)); if(auth_password(ssh_message_auth_user(message), ssh_message_auth_password(message))){ auth=1; ssh_message_auth_reply_success(message,0); break; }else{ printf("ssh password auth no correct,no such user,try pubkey\n"); // not authenticated, send default message try pubkey ssh_message_auth_set_methods(message,SSH_AUTH_METHOD_PUBLICKEY); ssh_message_reply_default(message); } case SSH_AUTH_METHOD_PUBLICKEY: printf("ssh log: user wants to connect with pubkey\n"); if(ssh_userauth_autopubkey(session,NULL) == SSH_AUTH_SUCCESS) { printf("ssh pubkey auth success: %s\n",ssh_get_error(session)); auth=1; ssh_message_auth_reply_success(message,0); break; }else{ printf("ssh pubkey auth error: %s\n",ssh_get_error(session)); } case SSH_AUTH_METHOD_NONE: default: printf("message auth type %d\n",ssh_message_subtype(message)); ssh_message_auth_set_methods(message,SSH_AUTH_METHOD_PASSWORD); ssh_message_reply_default(message); break; } break; default: ssh_message_reply_default(message); } ssh_message_free(message); } while (!auth); 2012-02-08 Linny.liang 梁玉林
Re: need help about how to use ssh_userauth_autopubkey | Andreas Schneider <asn@xxxxxxxxxxxxxx> |