cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libssh2 scp working?

From: James Housley <jim_at_thehousleys.net>
Date: Mon, 16 Oct 2006 06:24:27 -0400

On Oct 16, 2006, at 4:07 AM, Daniel Stenberg wrote:

> On Sun, 15 Oct 2006, James Housley wrote:
>
>> I have done some modifications and have scp getting a file
>> working. I know I have cleanup to do in configure.ac, but it
>> works. I also started with sftp, but jumped to scp because it is
>> simpler. Could I get a quick review of the direction I am headed in.
>
> Okay, having applied and tested it somewhat I have a few comments
> on it. I realize it is still fairly early, so ignore everything you
> think is too early or beside the point for now!
>
> No matter what, this is a good start to an even more powerful libcurl!
>
> - When built, it doesn't seem to work for me to scp from my test
> server? So I
> switched to try sftp instead and then I noticed that you have a
> wrong
> assumption on the given URL:

Right now scp works if you have copied your public key to the
server. It should work if you pass the password on the command
line. I also don't know if works with SSHv1.
>
> I tried downloading this:
>
> sftp://user:password@server/tmp/temp

sftp worked when this was part of 7.15.5, I haven't done any testing
in 7.16-CVS.

>
> (I have a 'temp' file in my tmp dir in the user's home directory)
>
> and I got this error back:
>
> Current remote directory: /home/user
> == Info: Couldn't open file /tmp/temp
> == Info: Closing connection #0
> curl: (37) Couldn't open file /tmp/temp
>
> ... which indicates that you use the initial slash when creating
> the path,
> while that should be used as a separator only! If I really wanted
> the root
> tmp dir, I would use "//tmp/temp" or even "/%2etmp/temp". (The
> latter is the
> way the RFCs dictate.)

This is one of the things I want to talk about.

I use scp a lot and my most common usage is

scp username_at_server:~/filename .

And from what you said, that would be cURL'd as

curl sftp://username@server/~/filename -O

But in the end I guess I have to look more closely at what ftp and
tftp do after calling curl_easy_unescape()

>
> And when I try sftp it seems it downloads something as the remote
> file is
> 619 bytes and I got to see:
>
> % Total % Received % Xferd Average Speed Time Time
> Time Current
> Dload Upload Total Spent
> Left Speed
> 100 619 100 619 0 0 1048 0 --:--:-- --:--:--
> --:--:-- 0
>
> and it hung right there and when I presse control-c the local
> file was zero
> bytes.
>
> Let me know if you think I should debug this more in my end.

I have stopped on sftp for the moment, because there other issues
with it and started on scp because it seems simple and a good way to
figure out the library internals first.

>
> - configure needs some more work, but you did mention that. It
> (wrongly) speaks of "openssh2" and you can remove the traces of
> USE_SSLEAY
> that you converted to USE_SSH2EAY which is pointless.

That is because I copied from FTP/FTPS.

>
> - version info. You should make the version struct return a pointer
> with
> libssh2 version info like the other libs do, and you should set a
> feature
> flag that says it can do SCP/SFTP!

I will look into that.

Thank you that is great feedback and nice to know I am on the right
track.

Jim

--
/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
  X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
jeh@FreeBSD.org      http://www.FreeBSD.org     The Power to Serve
jim@TheHousleys.Net  http://www.TheHousleys.net
---------------------------------------------------------------------
"Eagles may soar, but weasels don't get sucked into jet engines"
     -- Anon
Received on 2006-10-16