|
|
Posted by Jeremy on 10/26/07 21:35
Royan wrote:
> I'm trying to make use of ssh2_auth_pubkey_file() and login into
> remote machine.
>
> I've read somewhere that in order to make that function work I have to
> supply it with public key with specific format due to limitation of
> libssh2. The public key should look like this: <key_type>{1 space
> character}<key_data>
>
> Well it still does not work even if I change my public key file. Says
> "Authentication failed for <user_name> using public key" Can somebody
> help me and perhaps give an idea where to look next?
>
>
> Yes, unfortunately i can not use any other way of logging in to the
> remote PC, so username/password is not an option for me
>
Are you sure you have all the pieces in place for this? For it to work,
you must:
1) Have the public key installed on the remote server in the user's
authorized_keys file. The file (and sometimes the whole directory) must
have appropriate permissions (typically 600) or the server may ignore it.
2) Have both the private and public keys on the local machine (I'm not
sure why they require the pubkey, but they do). If the private key is
encrypted, you must also pass the passphrase to ssh2_auth_pubkey_file.
I have done this successfully without monkeying with the key files, so I
doubt that is your issue. Did you use OpenSSH to generate the keys? If
not, they could be in the wrong format - but you almost certainly did
use OpenSSH so the keys should be OK. I'm betting it's a problem on the
remote server (permissions) or the private key being encrypted.
Jeremy
Navigation:
[Reply to this message]
|