views:

97

answers:

2

Hello there,

I am having some problems with user authentications, I want the authentication through command prompt when user accesses it.

I'm opening session with libssh2_session_init(). Then, i'm using libssh2_userauth_keyboard_interactive() to enable user to input password at command prompt.

You can check the code at http://www.libssh2.org/examples/ssh2.html

I have implemented the whole function for remote command execution with ssh. If user provides password with libssh2_userauth_password(), it works perfect. But i'm not able to use libssh2_userauth_keyboard_interactive(). I don't know what to use for callback methods.

My code is:

        if (libssh2_userauth_keyboard_interactive(session, username,

                                                  &kbd_callback) ) {
            printf("\tAuthentication by keyboard-interactive failed!\n");
            return "AUTHENTICATIONFAILURE";

}

and my callback function is

static void kbd_callback(const char *name, int name_len, const char *instruction, int instruction_len, int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, void **abstract) { (void)name; (void)name_len; (void)instruction; (void)instruction_len; if (num_prompts == 1) { responses[0].text = strdup(pwd); responses[0].length = strlen(pwd); } (void)prompts; (void)abstract; } /* kbd_callback */

I don't know how to implement the callback function... would anyone help me please..?

Any sort of help would be appreciated.

Thanks.

A: 

If you get its answer please post it here... me too havin the same prob..

Suriya
A: 

Hi, May you post how to build a static library

I totally have no idea how to build a static library of Libssh2 or libssh so many files

aelam