0

My SSH server uses double authtication. I do not know how its implemented. But initially its asks for a password, then again asks for another password to login to a separate console which is different from usual control.

My code is similar to the example code shown in the documentations,

#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <libssh/libssh.h>


int main(int argc, char * argv[])
{
    ssh_session my_ssh_session = ssh_new();
    int rc;
    char * password;
    char * username = "admin";
    // Check if ssh session exists.
    if(my_ssh_session == NULL)    
    {
        exit(-1);
    }

    ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "x.x.x.x");

    rc = ssh_connect(my_ssh_session);
    if (rc != SSH_OK)
    {
        fprintf(stderr, "Error Connecting to Server: %s.\n", ssh_get_error(my_ssh_session));    
        exit(-1);
    }

    password = getpass("Password: ");
    rc = ssh_userauth_password(my_ssh_session, username, password);
    if (rc != SSH_AUTH_SUCCESS)
    {
        fprintf(stderr, "ERROR Authenticating: %s.\n", ssh_get_error(my_ssh_session));
        ssh_disconnect(my_ssh_session);
        ssh_free(my_ssh_session);
    }
    else
    {
        printf("Authentication Successful.\n");
    }

    ssh_free(my_ssh_session);
}

How do i implement a double authtication in this ? can you kindly help me out ?

Bala
  • 381
  • 3
  • 16

1 Answers1

0

What version of libssh do you have?

"versions 0.5.1 and above have a logical error in the handling of a SSH_MSG_NEWKEYS and SSH_MSG_KEXDH_REPLY package. A detected error did not set the session into the error state correctly and further processed the packet which leads to a null pointer dereference. This is the packet after the initial key exchange and doesn’t require authentication."

Ref libssh