From a935ad1857b91b6aa179d14137f520d978647341 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Sat, 25 Jul 2009 17:03:01 +0200 Subject: New example directory with the begining of a scp --- examples/authentication.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 examples/authentication.c (limited to 'examples/authentication.c') diff --git a/examples/authentication.c b/examples/authentication.c new file mode 100644 index 0000000..06a0b71 --- /dev/null +++ b/examples/authentication.c @@ -0,0 +1,114 @@ +/* + * authentication.c + * This file contains an example of how to do an authentication to a + * SSH server using libssh + */ + +/* +Copyright 2003-2009 Aris Adamantiadis + +This file is part of the SSH Library + +You are free to copy this file, modify it in any way, consider it being public +domain. This does not apply to the rest of the library though, but it is +allowed to cut-and-paste working code from this file to any license of +program. +The goal is to show the API in action. It's not a reference on how terminal +clients must be made or how a client should react. + */ + +#include +#include +#include +#include + +#include +#include "examples_common.h" + +int authenticate_kbdint(ssh_session session){ + int err=ssh_userauth_kbdint(session,NULL,NULL); + const char *name, *instruction, *prompt; + char *ptr; + char buffer[128]; + int i,n; + char echo; + while (err==SSH_AUTH_INFO){ + name=ssh_userauth_kbdint_getname(session); + instruction=ssh_userauth_kbdint_getinstruction(session); + n=ssh_userauth_kbdint_getnprompts(session); + if(strlen(name)>0) + printf("%s\n",name); + if(strlen(instruction)>0) + printf("%s\n",instruction); + for(i=0;i