llass61 has asked for the wisdom of the Perl Monks concerning the following question:

I am running perl 5.10.0 build 1004 on windows XP. I have ssh2 version .18 installed. I am trying to use Net::SSH2->scp_get and/or scp_put. I get the following error:
-22LIBSSH2_ERROR_CHANNEL_REQUEST_DENIEDUnable to complete request for +channel-process-startup
Do I need the remote site enabled for scp?
What am I doing wrong?

Here is my code:
use Net::SSH2; my $host = 'ftp.??????.com'; my $user = 'user'; my $password = 'password'; $ssh2 = Net::SSH2->new(); print "\nconnecting to $host...\n"; $ssh2->connect($host); print "\nauth to $host...\n"; $ssh2->auth_password($user,$password); print "\ngetting sftp hdl...\n"; my $sftp = $ssh2->sftp(); print "scp get\n"; $ssh2->scp_get("test/out/Tesia220044-20081029175508-03.txt", "./aaa.tx +t"); print $ssh2->error, "\n";
Thanks for any help!!!!!!!!

Replies are listed 'Best First'.
Re: ssh2 open file problem
by afresh1 (Hermit) on Oct 31, 2008 at 16:41 UTC

    My first guess would be that you are first changing to 'test/out' then trying to retrieve 'test/out/file'. It seems unlikely that there exists 'test/out/test/out/file'. I would try either not changing directories or just get 'file'. I am testing to see if I can reproduce, but that sounds the most likely.

    UPDATE 1: Nevermind all that. I see now that you get a $sftp object and do the opendir on that, then return to $ssh2->scp_get. However, having said that, in my test environment, I get a core dump when I scp_get so I will need to find another test environment.

    UPDATE 2: I have tried it on a 32bit arch instead of 64bit and it doesn't core dump. And, even better, it works fine to transfer the file. I copied your script and just changed $host, $user and $password and copied a test file in '~/test/out/' to 'aaa.txt'.

    Does it appear that it is getting the sftp handle that isn't working, or the scp_get?

    Can you SFTP and scp the files with the normal commands, not using perl?

    Can you try it with debug enabled?

    Maybe try this?

    #!/usr/bin/perl use strict; use warnings; use Net::SSH2; my $host = ''; my $user = ''; my $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/Tesia220044-20081029175508-03.txt") or die $s +sh2->error; $ssh2->disconnect();

    l8rZ,
    --
    andrew
      Sorry about the code, I forgot to take out the opendir. I just updated it. That was part of my second question in another msg. Anyway, I tried the code that you asked and got the same thing. Here is the error msg:
      connecting to ftp.realtimeclaims.com... auth to ftp.realtimeclaims.com... Auth OK: 4 scp get libssh2_scp_recv(ss->session, path, &st) -> 0x0 -22LIBSSH2_ERROR_CHANNEL_REQUEST_DENIEDUnable to complete request for +channel-pr ocess-startup at sftp2.pl line 24. Net::SSH2::DESTROY object 0x183532c

      thanks for any help (again).