/* * 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