[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Double authentication using libssh
[Thread Prev] | [Thread Next]
- Subject: Re: Double authentication using libssh
- From: Tilo Eckert <tilo.eckert@xxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 29 Jul 2015 12:16:43 +0200
- To: libssh@xxxxxxxxxx
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.
Re: Double authentication using libssh | balasubramanian Achuthan <balasurfs@xxxxxxxxx> |
Double authentication using libssh | balasubramanian Achuthan <balasurfs@xxxxxxxxx> |