[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private key login from windows and mingw


Hello,

I think you miss an ssh_connect() somewhere. I agree that libssh should give a more useful error message like "not connected". Otherwise your pubkey authentication seems right to me.

Regards,

Aris

Le 5/07/12 20:23, Alfonso Arbona Gimeno a écrit :
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello list,

I'm having some trouble understanding how to login using a private key.
This is what I do:

my_ssh_session = ssh_new();
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, server);
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);

privkey = privatekey_from_file(my_ssh_session, "C:\\data\\privatekey",
0, "pass");

rc = ssh_userauth_pubkey(my_ssh_session, "root", NULL, privkey);
if(rc != SSH_AUTH_SUCCESS)
	error....

privatekey_free(privkey);
...

And the output I get says:
[1] Trying to open C:\data\privatekey
[1] Trying to read C:\data\privatekey, passphase=true, authcb=false
[3] Writing on the wire a packet having 17 bytes before
[3] 17 bytes after comp + 10 padding bytes = 28 bytes packet
[1] Error : Writing packet: error on socket (or connection closed):
Unknown error
[3] Sent SSH_MSG_SERVICE_REQUEST (service ssh-userauth)


I've been trying to follow the examples and I've read the api, the
documentation and even part of the source code but I don't understand
what is happening here.
By the way, my ssh server only accepts certificate login, however I
can login using Putty (with a copy of the same certificate exported to
be putty-compatible), and I can also login to ssh from other programs
such as MySQL Workbench using exactly the same certificate.

In fact, I could connect when my server was configured to use a
password login, but I wanted more security than just a plain password.
That's why I am confused about the socket error...

I'm using the precompiled binaries for MinGW, version 0.5.2-1

Any idea?
And thanks in advance,

Alfonso Arbona
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJP9dugAAoJECPrtc1S8vx5g4AH/Ai/QZm7o2tb76OQ1BmhxAIt
LjlNenLGfba6XzWzzN2JxpfTgo2VZgHObdl0hoN9eEp5eeNwG4BvJRdi4cw8vIct
s9XmHqtqKJ3DMmQ94IQgA/Ju4ng3umicWDD62a7cdkeAhvhKEvB6QU5XKbeIvPBh
7INh+0aCqRB7obd+LkdoiaTPlp3pceZ4/OroR8glVgzu1G9ASAAFHYosSYBqv5y0
DoN54oIabn4GwHXB4MFFOQcbdsOMm3bIXlBsrb2ZcSzeqmHECJcmx5mt0MYcS9zf
mPDMbPeK3lId9BtDhQ29+LMOIlvBwoBDlaU2QMQ7/KBx+PxKYMD5mfMWZbZ3sNw=
=pr2g
-----END PGP SIGNATURE-----





Follow-Ups:
Re: Private key login from windows and mingwAlfonso Arbona Gimeno <nake90@xxxxxxxx>
References:
Private key login from windows and mingwAlfonso Arbona Gimeno <nake90@xxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org