[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Double authentication using libssh


Hi Tilo,

Thanks, This was just a bare stripped down version. The actual version
looks different.

So how do i pass the second password? should i again use
ssh_userauth_password ? again?

I went through the tutorial. The answer for my question is not there. API
docs does not say anything about this SSH_AUTH_PARTIAL.

Thank,
Bala.

On Wed, Jul 29, 2015 at 3:46 PM, Tilo Eckert <tilo.eckert@xxxxxxx> wrote:

> Hi
>
> if the server requires multiple authentication steps, the authentication
> functions return SSH_AUTH_PARTIAL for any partial authentication step.
> Only after the last step, SSH_AUTH_SUCCESS is returned, indicating
> successful login.
>
> Some notes on your implementation:
> - You should set the username through ssh_options_set().
> - You have no host key validation (aka known_hosts check). Without it,
> you have no security at all.
> - You release the session handle without disconnecting.
> - Your main() never returns anything, but has return type int.
>
> I suggest reading the tutorials about properly setting up an SSH
> connection at:
> http://api.libssh.org/master/libssh_tutorial.html
>
> Regards,
> Tilo
>
> Am 29.07.2015 um 11:59 schrieb balasubramanian Achuthan:
> > Hi All,
> >
> > 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 ?
> >
> > Thanks,
> > Bala.
>
>
>

Follow-Ups:
Re: Double authentication using libsshAndreas Schneider <asn@xxxxxxxxxxxxxx>
Re: Double authentication using libsshAris Adamantiadis <aris@xxxxxxxxxxxx>
References:
Double authentication using libsshbalasubramanian Achuthan <balasurfs@xxxxxxxxx>
Re: Double authentication using libsshTilo Eckert <tilo.eckert@xxxxxxx>
Archive administrator: postmaster@lists.cynapses.org