Subject: Re: Using keys for private key

Re: Using keys for private key

From: Ted Lemon <>
Date: Sat, 24 Jul 2010 03:13:44 -0400

On Jul 24, 2010, at 3:07 AM, Paresh Thakor wrote:
> So, i need to implement private key in my application. So, is this possible with libssh2? This is critical.

Yes. Instead of using libssh2_userauth_password(), use libssh2_userauth_publickey_fromfile():

      rc = libssh2_userauth_publickey_fromfile(session,
                                               "username", [pubkey UTF8String],
                                               [privkey UTF8String], "");

The pubkey and privkey variables in the example are NSStrings containing the path to the file. There's also an API for doing it from memory, but I haven't tried that.

Received on 2010-07-24