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

I decided to give net::sftp a try again. I'm getting a little farther, but still not quite there. It seems to hang whenever I try to connect so a site. This is the code: *************************
use Net::SFTP; my %args = ( user => 'ME', debug => '1', password => 'PASS' ); my $sftp = Net::SFTP->new('localhost', %args); print "Connected.....\n"; exit(0); } else { warn "auth failed.\n"; }
It hangs, this is the response I get.
hipaatest: Reading configuration data /dev/fs/D/home/hipaa/.ssh/config hipaatest: Reading configuration data /etc/ssh_config hipaatest: Connecting to localhost, port 22. hipaatest: Remote version string: SSH-1.99-OpenSSH_4.6 hipaatest: Remote protocol version 1.99, remote software version OpenS +SH_4.6 Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::Fas tCalc at C:/Perl/site/lib/Crypt/DH.pm line 6 hipaatest: Net::SSH::Perl Version 1.30, protocol version 2.0. hipaatest: No compat match: OpenSSH_4.6. hipaatest: Connection established. hipaatest: Sent key-exchange init (KEXINIT), wait response. hipaatest: Algorithms, c->s: 3des-cbc hmac-sha1 none hipaatest: Algorithms, s->c: 3des-cbc hmac-sha1 none hipaatest: Entering Diffie-Hellman Group 1 key exchange. hipaatest: Sent DH public key, waiting for reply. Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::Fas tCalc at C:/Perl/site/lib/Crypt/DSA/KeyChain.pm line 6 Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::Fas tCalc at C:/Perl/site/lib/Crypt/DSA/Key.pm line 6 Math::BigInt: couldn't load specified math lib(s), fallback to Math::B +igInt::Fas tCalc at C:/Perl/site/lib/Crypt/DSA/Util.pm line 6 hipaatest: Received host key, type 'ssh-dss'. hipaatest: Host 'localhost' is known and matches the host key. hipaatest: Computing shared secret key. hipaatest: Verifying server signature. hipaatest: Waiting for NEWKEYS message. hipaatest: Enabling incoming encryption/MAC/compression. hipaatest: Send NEWKEYS, enable outgoing encryption/MAC/compression. hipaatest: Sending request for user-authentication service. hipaatest: Service accepted: ssh-userauth. hipaatest: Trying empty user-authentication request. hipaatest: Authentication methods that can continue: publickey,passwor +d,hostbase d. hipaatest: Next method to try is publickey. hipaatest: Next method to try is password. hipaatest: Trying password authentication. hipaatest: Login completed, opening dummy shell channel. hipaatest: channel 0: new [client-session] hipaatest: Requesting channel_open for channel 0. hipaatest: channel 0: open confirm rwindow 0 rmax 32768 hipaatest: channel 1: new [client-session] hipaatest: Requesting channel_open for channel 1. hipaatest: Sending subsystem: sftp hipaatest: Requesting service subsystem on channel 1. hipaatest: channel 1: open confirm rwindow 0 rmax 32768 hipaatest: sftp: Sending SSH2_FXP_INIT
Any help would be greatly appreciated. Larry

Replies are listed 'Best First'.
Re: problem with net::sftp
by leocharre (Priest) on Jul 24, 2008 at 02:14 UTC

    Ok, you may not wanna hear this one.. but...

    I had a problem with Net::SCP a while back. I was kinda upset, because it seemed like a good idea to use that instead of making system calls.

    I recently used Net::SCP again, and voila- no problems. What had happened? There was a new version of Net::SCP- one that fixed some previous bug.

    Consider checking your version against that on cpan.

      from the original post:
      hipaatest: Net::SSH::Perl Version 1.30, protocol version 2.0.
      And searching for Net::SSH::Perl on CPAN reveals that it is the latest version!
Re: problem with net::sftp
by aquarium (Curate) on Jul 24, 2008 at 01:16 UTC
    Hi Larry...as things get harder--as they inevitably do--start making things simpler and under your control. e.g. run your own sftpd daemon on same machine, for testing..and so on. btw do you need to use a proxy.
    the hardest line to type correctly is: stty erase ^H
Re: problem with net::sftp
by Khen1950fx (Canon) on Jul 24, 2008 at 21:55 UTC
    There seems to be a problem with Math::BigInt. The Makefile.PL recommends that the "recommends" be updated, so I included a little update in the script. This worked for me:

    #!/usr/bin/perl use strict; use warnings; use CPAN; use Net::SFTP; CPAN::Shell->install( "Math::BigInt", "Math::BigInt::FastCalc", "Math::BigInt::GMP", "Math::BigInt::Pari", "Math::BigRat", "bignum", "Crypt::DSA", "Crypt::DH"); my %args = ( user => 'user', password => 'password', debug => '1'); my $sftp = Net::SFTP->new('localhost', %args); print "Connected.....\n" if $sftp;
      Thanks for this post After installing all of those packages I still hang in the exact same spot as OP. I did notice that it has to do with us running in a mod_perl env. If ran from the command line or a reg perl file by apache it works like a charm. My sys admins are at a loss and so am I as to which ENV settings are wrong. Any further help would be most appreciated
Re: problem with net::sftp
by salva (Canon) on Jul 24, 2008 at 07:01 UTC
    Are you able to connect to the remote host with the sftp client?

    Looking at your previous posts, it seems that your problem, actually, is finding a way to connect to a SFTP server. Read Re^3: package that can handle ftp, sftp, http etc ? for a description of the options currently available.