Maybe I should backup to what my actual goal is: I'd like to be able SFTP to an unknown host. CURL (and libcurl) seem to insist that a host exist in the known_hosts file before allowing an SFTP session.
curl on the command line like this: curl -u myusername sftp://ftp.example.com fails with a "curl: (51) SSL peer certificate or SSH remote key was not OK" error. Once I add my server to the known_hosts file, all is well. The sftpdir.c example that comes with libssh2 works perfectly, even without an entry for my server in the known_hosts file. Any ideas? _murat On Feb 20, 2011, at 3:33 PM, Daniel Stenberg wrote: > On Sun, 20 Feb 2011, [email protected] wrote: > >> I am trying to get SFTP support working using libcurl. I am setting a >> keyFunction like this: >> >> curlcode = curl_easy_setopt(curl, CURLOPT_SSH_KEYFUNCTION, _keyFunction); >> >> but my key function never gets called when I try to connect to an SFTP >> server. I'm kind of surprised by this. Is this common? Under what >> circumstances should it get called? The docs seem to say that it should >> always be called. > > It always gets called if set! It only ever not gets called if your libcurl > was built with an old libssh2 present that doesn't have the required > knownhost API... > > (see lib/ssh.c line 661) > > So, if you really don't get it called I think you should set a break-point in > the libcurl code and figure out how you manage to avoid it, and then tell us! > > -- > > / daniel.haxx.se > ------------------------------------------------------------------- > List admin: http://cool.haxx.se/list/listinfo/curl-library > Etiquette: http://curl.haxx.se/mail/etiquette.html ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
