in reply to ssh2 scp question

The second error seems to indicate that you tried to connect to the other server with the username "MyUserName" instead of something like "john" or "Theodor".

Since you didn't post your code it is nearly impossible for us to find out if the bug is in your or the modules code.

Replies are listed 'Best First'.
Re^2: ssh2 scp question
by llass61 (Novice) on Nov 12, 2008 at 21:27 UTC
    This is my test script for trying to get/put files using ssh2->scp_???

    use strict; use warnings; use Net::SSH2; my $host = 'ftp.?????.com'; my $user = 'user'; my $password = 'password'; my $ssh2 = Net::SSH2->new(); $ssh2->debug(1); print "\nconnecting to $host...\n"; $ssh2->connect($host) or die $ssh2->error; print "\nauth to $host...\n"; $ssh2->auth_password($user,$password) or die $ssh2->error; printf "Auth OK: %s\n", $ssh2->auth_ok; print "scp get\n"; $ssh2->scp_get("test/out/MyFile-03.txt") or die ssh2->error; $ssh2->disconnect();


    I also used the opensource WinSCP to test out the connections and got errors when trying to use scp.
      Using your script on my Win32 box to connect to an SSH2 server on my linux box, I find that the connection is made without any trouble at all.
      However, the 'scp_get' call segfaults, and I get the following error message:
      libssh2_scp_recv(ss->session, path, &st) -> 0x2b849a4
      If I try an 'scp_put' I get a similar message (and segfault):
      libssh2_scp_send_ex(ss->session, path, mode, size, mtime, atime) -> 0x +2b8a0d4
      I find that the file I tried to upload with 'scp_get' was created in the correct location on the server ... but is empty :-(
      The test script that ships with the Net-SSH2 source, constructs the 'scp_get' call a little differently (though that's not the problem, afaict). It does:
      my $check = IO::Scalar->new; $ssh2->scp_get($remote, $check);
      I hadn't realised scp wasn't working on Windows. (I failed to notice that, since IO::Scalar was not installed, the scp tests were being skipped.) OTOH, sftp seems to work fine
      I'm using Net-SSH2-0.18 on perl-5.10.

      Update: Just noticed that 'scp_put' and 'scp_get' both work ok for me on perl-5.8.8, Win32. If you're using Win32, and you really do need scp, then 5.8.8 is probably the simplest way to achieve it.

      Cheers,
      Rob
        You might want to apply the following patch if you want to run Net::SSH2 on perl-5.10.

        http://rt.cpan.org/Public/Bug/Display.html?id=36614

        I got bitten by that bug also..