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

Technically, the error I'm seeing is from Net::SSH::Perl, but it cropped up through use of Net::SFTP.

I have a very small script that I'm using to test connectivity with an SFTP server:

#!/usr/bin/perl -l use strict; use Net::SFTP; my ( $host, $user, $pass ) = ( ... ); my $sftp = Net::SFTP->new( $host, user => $user, password => $pass, ssh_args => [ debug => 1 ] );
However, there seems to be a problem with this that I have been unable to track down so far:
%perl sftp_test.pl Reading configuration data /usr/home/*****/.ssh/config Reading configuration data /etc/ssh_config Connecting to *************, port 22. Remote version string: SSH-2.0-VShell_2_3_1_151 VShell Remote protocol version 2.0, remote software version VShell_2_3_1_151 + VShell Net::SSH::Perl Version 1.30, protocol version 2.0. No compat match: VShell_2_3_1_151 VShell Connection established. Sent key-exchange init (KEXINIT), wait response. Algorithms, c->s: 3des-cbc hmac-sha1 none Algorithms, s->c: 3des-cbc hmac-sha1 none Entering Diffie-Hellman Group 1 key exchange. Sent DH public key, waiting for reply. Received disconnect message: Invalid packet header. This probably ind +icates a problem with key exchange or encryption. at /usr/local/lib/p +erl5/site_perl/5.8.4/Net/SSH/Perl/Kex/DH1.pm line 41

I am able to connect to the server through the sftp command line utility just fine. The module usage seems to be pretty straight-forward, but I suppose I could be missing something. I've tried passing it both SSH1 and 2, and all of the compatible cyphers for each through 'ssh_args', but with no luck.

If anyone more experienced than I with Net::SFTP or Net::SSH::Perl could shine some light on this for me, that would be most excellent.

-Andy

Replies are listed 'Best First'.
Re: Net::SFTP 'invalid packet header'
by zentara (Cardinal) on May 05, 2008 at 16:48 UTC
    That module is old, problematic, and being replaced because of the types of problems you mention. If possible, try Net::SSH2 See A little demo for Net::SSH2

    If you are forced to use the old modules, try upgrading all the dependency modules to the latest versions.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Net::SFTP 'invalid packet header'
by pileofrogs (Priest) on May 05, 2008 at 16:43 UTC

    I've played around with Net::SSH::Perl, and my impression was that it was just too slow. There aren't many things where the perl implementation is too slow for me, but this was one of them. I've used openssh in batch mode or driven by Expect.

    Do your connections work with a regular SSH client?

    Is your ultimate goal a script that determines if the SSH server is running? If so, you could probably just connect an unencrypted TCP socket and read the SSH version info (or lack thereof). If you need to make sure the SSH server is functional, IE you need to log in, you might consider running ssh in batch mode with ssh keys or using expect.

Re: Net::SFTP 'invalid packet header'
by timecatalyst (Acolyte) on May 05, 2008 at 16:53 UTC
    Those are both great suggestions, but my ultimate goal is to submit files to this server on a weekly basis. Maybe I should look into a different SFTP module.

      Use scp and ssh keys. That's exactly what they're for.