Subject: Re: "Callback returned error" with public key authentication, under windows, linux works

Re: "Callback returned error" with public key authentication, under windows, linux works

From: Peter Stuge <peter_at_stuge.se>
Date: Tue, 11 May 2010 16:02:43 +0200

Bart Simpson wrote:
> But on a windows system only password authentication works. The
> problem is i need public key authentication for my project.

I suggest that you use the agent support. Use libssh2-1.2.4 or later.

The agent support uses ssh-agent on Linux and Pageant on Windows.

Bart Simpson wrote:
> But i do not understand the difference between linux and windows.
> I have exactly the same code and the same keyfile in both versions.

src/userauth.c file_read_publickey() has this code:

    /* Read Public Key */
    fd = fopen(pubkeyfile, "r");
    if (!fd) {
        return _libssh2_error(session, LIBSSH2_ERROR_FILE,
                              "Unable to open public key file");
    }
    while (!feof(fd) && (c = fgetc(fd)) != '\r' && c != '\n')
        pubkey_len++;

You could try to change "r" in the call to fopen() into "rb" instead.

If you're not comfortable recompiling libssh2 then run unix2dos or
something similar on the key files, to convert their line endings.

I think we should be line ending agnostic in libssh2, so the code
above should be fixed. I'll have a look.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-05-11