Subject: Re: Key-based authentication with libssh2_userauth_publickey_fromfile()

Re: Key-based authentication with libssh2_userauth_publickey_fromfile()

From: Paresh Thakor <>
Date: Sat, 11 Sep 2010 10:47:25 +0530

Thanks, okay, i'll get work on it again and test it. About format of public key i need to work, and will test it. But my main question is generation of the key-pair, I don't know my key file format might be wrong or generated key might be wrong, but i don't know what is the problem.

But i have put the file in right format few days back and i have also done that copying file and other process on remote host to which i want to connect.

So, i don't know the function return right keypair or not. Do i need to do any other things for key generation or Security.framework's SecKeyGeneratePair() is okay?

Paresh Thakor.

On Sep 11, 2010, at 10:39 AM, Ted Lemon wrote:

> On Sep 11, 2010, at 12:58 AM, Paresh Thakor wrote:
>> Yes, right they are path to the files where our public/private keys are being stored. But I think i generate key-pair using Security.framework, SecKeyGeneratePair(). But i don't think this function returns me proper key-pair, because i have generated keypair using other programs which gives me different pair than what i get from the above function. So, i can't authenticate using keypair. Do i need to do any encoding, decoding for the keypair? Anything more can you suggest me so i can implement public/private keys?
> Hm, I thought I sent you a pretty detailed suggestion for how to do this a while back. My suggestion involved using the in-memory version of userauth_publickey instead of the one that loads the key from a file. That would probably work with the key you generate with SecKeyGeneratePair(). However, you would still need to get the public key into the authorized keys file on the host you're trying to connect to.
> For that, as you say, you need to write the public key in the right format. I don't actually know what that is, but looking at my own file, it looks like if you output a line that starts with the letters "ssh-dss " (don't include the quotes), and is followed by the base-64 representation of the public key, and ends with a key name (usually username_at_hostname), followed by a newline, that ought to work. But I haven't tried it, so I could easily be wrong.
> _______________________________________________
> libssh2-devel

Received on 2010-09-11