www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: Multiple authentications for SFTP connection

Re: Multiple authentications for SFTP connection

From: Jakob Egger <jakob_at_eggerapps.at>
Date: Thu, 4 Feb 2016 15:39:25 +0100

Yes, you just need to do both -> first publickey, which will fail, and then password or keyboard-interactive, which will succeed.

The process is something like this:

1) check which auth methods are allowed using libssh2_userauth_list()
2) try to authenticate using one of the methods
3) if it fails, go back to (1)

You should probably somehow keep track what you've tried to avoid an infinite loop.


> On 04 Feb 2016, at 13:48, Keith Martin <kthmrtn24_at_gmail.com> wrote:
> Hi,
> I'm trying to connect to a SFTP service which requires both username/password and public/private key authentication at the same time.
> I can connect using the command line SFTP, for example:
> sftp -o "IdentityFile=keyfile.txt" username_at_server.com <mailto:username_at_server.com>
> Connecting to server.com...
> EFT Server Enterprise passphrase for key 'keyfile.txt':
> Authenticated with partial success.
> Enter password:
> sftp>
> What I can't figure out is a way within libssh2 to perform both of these authentication steps. If I try either libssh2_userauth_publickey_frommemory or libssh2_userauth_password both of these return an immediate failure.
> Is there any way within libssh2 to get this form of double authentication?
> Regards,
> Keith.
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2016-02-04

the libssh2 team