From f9f8ded7f0a691c0b46ccff596944ef1b06cf8a8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 29 Dec 2008 11:33:51 +0000 Subject: Add a more generic auth callback function. You should be able to obtain passwords or usernames with this function. Signed-off-by: Andreas Schneider git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@198 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/auth.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libssh/auth.c') diff --git a/libssh/auth.c b/libssh/auth.c index a070750..eb212f7 100644 --- a/libssh/auth.c +++ b/libssh/auth.c @@ -405,6 +405,9 @@ static char *pub_keys_path[]={NULL,"%s/.ssh/identity.pub","%s/.ssh/id_dsa.pub"," * asker for passphrases (in case the private key is encrypted) * \brief Tries to automaticaly authenticate with public key and "none" * \param session ssh session + * \param passphrase use this passphrase to unlock the privatekey. Use + * NULL if you don't want to use a passphrase or the + * user should be asked. * \returns SSH_AUTH_ERROR : a serious error happened\n * SSH_AUTH_DENIED : Authentication failed : use another method\n * SSH_AUTH_PARTIAL : You've been partially authenticated, you still have to use another method\n @@ -414,7 +417,7 @@ static char *pub_keys_path[]={NULL,"%s/.ssh/identity.pub","%s/.ssh/id_dsa.pub"," * \see ssh_options_set_identity() */ -int ssh_userauth_autopubkey(SSH_SESSION *session){ +int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) { int count=1; /* bypass identity */ int type=0; int err; @@ -460,7 +463,7 @@ int ssh_userauth_autopubkey(SSH_SESSION *session){ continue; } /* pubkey accepted by server ! */ - privkey=privatekey_from_file(session,privkeyfile,type,NULL); + privkey=privatekey_from_file(session,privkeyfile,type,passphrase); if(!privkey){ ssh_say(0,"Reading private key %s failed (bad passphrase ?)\n",privkeyfile); free(pubkey); -- cgit