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

Hello, guys.
I'm working with perl now and i've faced with a problem with creating the script for connecting to SFTP server using perl modules Net::SFTP and Net::SSH::W32Perl. I would be really glad, if you could help me. I've spent a lot of days trying to solve my problem. I'm creating a script for copying the file from my local machine to a remote host via SFTP. The problem is that after loginning to server the program hangs on:

channel 1: open confirm rwindow 0 rmax 32768

I've searched a lot about this and I figured out that for escaping this problem I need to installing SFTP and SSH modules from repository on the website http://www.soulcage.net/ppds/ can solve this problem. But this website does not exist any more. So I was wondering, may be someone know where to find these modules, so my programm would work. Cause I've tried a lot of them from different repositories, but it didn't help me. Or may be there's any other way to solve this. I would appreciate any help.
Here's the script:
#!usr/local/bin/perl -w use Net::SSH::W32Perl; use Net::SFTP; BEGIN { $ENV{HOME} = $ENV{APPDATA} || $ENV{USERPROFILE} } print "\nTryin' to connect. Please wait...\n"; my $login="****"; my $pass="****"; my $host='***.***.***.***'; my @args=(user => $login, password => $pass, ssh_args => [port=>22, debug => 1]); my $localfile='D:\\test.txt'; my $remotefile='/folder1/folder2/folder3/folder4/folder5'; my $sftp; $sftp=Net::SFTP->new($host, @args); $sftp->error and die "Connection failed: " . $sftp->error; print "\nConnection was established successfully\n"; $sftp->put($localfile, $remotefile) or die "Can't put file: $!\n"; $sftp->close() or die "Disconnect error: $!\n"; print "ok";
Here's the log:

myuser: Connecting to ***.***.***.***, port 22. myuser: Remote version string: SSH-2.0-OpenSSH_4.3 myuser: Remote protocol version 2.0, remote software version OpenSSH_4 +.3 myuser: Net::SSH::Perl Version 1.30, protocol version 2.0. myuser: No compat match: OpenSSH_4.3. myuser: Connection established. myuser: Sent key-exchange init (KEXINIT), wait response. myuser: Algorithms, c->s: 3des-cbc hmac-sha1 none myuser: Algorithms, s->c: 3des-cbc hmac-sha1 none myuser: Entering Diffie-Hellman Group 1 key exchange. myuser: Sent DH public key, waiting for reply. myuser: Received host key, type 'ssh-dss'. myuser: Host '***.***.***.***' is known and matches the host key. myuser: Computing shared secret key. myuser: Verifying server signature. myuser: Waiting for NEWKEYS message. myuser: Enabling incoming encryption/MAC/compression. myuser: Send NEWKEYS, enable outgoing encryption/MAC/compression. myuser: Sending request for user-authentication service. myuser: Service accepted: ssh-userauth. myuser: Trying empty user-authentication request. myuser: Authentication methods that can continue: publickey,gssapi-wit +h-mic,password. myuser: Next method to try is publickey. myuser: Next method to try is password. myuser: Trying password authentication. myuser: Login completed, opening dummy shell channel. myuser: channel 0: new [client-session] myuser: Requesting channel_open for channel 0. myuser: channel 0: open confirm rwindow 0 rmax 32768 myuser: channel 1: new [client-session] myuser: Requesting channel_open for channel 1. myuser: Sending subsystem: sftp myuser: Requesting service subsystem on channel 1. myuser: channel 1: open confirm rwindow 0 rmax 32768
And then programm hangs.
Pleasu, hepl me with this trouble. Waiting for your reply.

Replies are listed 'Best First'.
Re: Net::SFTP. Script hangs. Bad repository?
by zentara (Cardinal) on Aug 09, 2010 at 12:12 UTC
      Thanks a lot, zentara. You helped me so much! I've tried SSH2 and it works perfectly. The problem is solved. Thanks again!
Re: Net::SFTP. Script hangs. Bad repository?
by moritz (Cardinal) on Aug 09, 2010 at 10:20 UTC
    Start with simple things: can you transfer files with the scp command line client, with the same user name and ssh key?

    If not, it could be something as simple as a hanging network file system on the server side.

    Perl 6 - links to (nearly) everything that is Perl 6.
Re: Net::SFTP. Script hangs. Bad repository?
by Khen1950fx (Canon) on Aug 09, 2010 at 12:12 UTC
    I cleaned it up. Try this:
    #!perl use strict; use warnings; use Net::SFTP; my $host = 'localhost'; my $user = 'user'; my $pass = 'password'; my %args = ( user => $user, password => $pass, port => 22, debug => 1 ); my $local = 'D:\\test.txt'; my $remote = '/dir1/dir2/test.txt'; my $sftp = Net::SFTP->new($host, %args); die "Can't put file: $!\n" unless $sftp->put($local, $remote); close $local;
    Update: Fixed typo.