cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: connecting to sftp where server is not trusted yet

From: Miro Janosik <miro.janosik_at_gmail.com>
Date: Fri, 14 Oct 2016 07:39:07 +0200

> From: Dan Fandrich <dan_at_coneharvesters.com>
> Date: Sat, 8 Oct 2016 09:36:19 +0200
>
> > curl_easy_setopt(m_session, CURLOPT_URL, "ftp.server.com");
>
> This isn't a proper URL; it's just a host name. curl is going to guess at the
> protocol in this case, and it' going to guess FTP, not SFTP. Try setting a URL
> like sftp://ftp.server.com/ and see if it works any better.

Thank you. After I added sftp:// I am getting a message:
"* Protocol "sftp" not supported or disabled in libcurl"

doh, so it looks to me that sftp is not built-in in the curl? And I
have to recompile ... I will try to follow some document that
describes it, probably
http://andrewberls.com/blog/post/adding-sftp-support-to-curl

> > curl_easy_setopt(curlSession, CURLOPT_DIRLISTONLY, 1);
> > curl_easy_setopt(curlSession, CURLOPT_VERBOSE, 1);
>
> These two must be long, not int; use 1L instead.

It worked for me without L, but you are right, I will update it.

> > I see this in verbose console:
> >
> > Started
> > * Rebuilt URL to: ftp.server.com/
> > * Trying 111.33.111.11...
> > * TCP_NODELAY set
> > * Connected to ftp.server.com (111.33.111.11) port 22 (#0)
> > < SSH-2.0-mod_sftp/0.9.9
> > * Operation timed out after 300281 milliseconds with 0 out of 0 bytes received
> > * Closing connection 0
> >
> > I'd like to make my code work without user's interaction (as I have username
> > and password) and it should check if the host key is correct.
> >
> > I'm missing some functions that would return me the server's host key so I
> > could compare it to my local key; and then approving the server that it is ok
> > to connect.
>
> curl will do this for you when you set CURLOPT_SSH_HOST_PUBLIC_KEY_MD5

Okay, it will do it for me, but how will I get the information if the
server's key has changed (something like the message 'key is unknown,
do you agree to proceed')? I mean if server's key has changed/is
unknown then user should approve the connection, right?

 thanks, Miro

> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html
> Received on 2016-10-08
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-10-16