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

I am trying to automate the retrieval of a set of files from multiple
servers with different logins and passwords. When I try to use
scalars to change the user name and passwords it fails with a complaint
that I don't have enough input for DES to work. So, this works:
my %parms = ( user => “phil”, password => “testme” ); my $sftp = Net::SFTP->new($sadder, % parms) ;

it connects and I can get stuff. On the other hand, this won't:

my $user = “phil” ; my $pass = “testme” ; my %parms = ( user => $user, password => $pass) ; my $sftp = Net::SFTP->new($sadder, % parms) ;

I get the debug output:

bast: Reading configuration data /home/mumble/.ssh/config bast: Reading configuration data /etc/ssh_config bast: Connecting to mumble.mumble.mumble.mumble, port 22. bast: Remote protocol version 1.99, remote software version OpenSSH_3. +5p1 bast: Net::SSH::Perl Version 1.25, protocol version 2.0. bast: No compat match: OpenSSH_3.5p1. bast: Connection established. bast: Sent key-exchange init (KEXINIT), wait response. bast: Algorithms, c->s: 3des-cbc hmac-sha1 none bast: Algorithms, s->c: 3des-cbc hmac-sha1 none bast: Entering Diffie-Hellman Group 1 key exchange. bast: Sent DH public key, waiting for reply. bast: Received host key, type 'ssh-dss'. bast: Host 'mumble.mumble.mumble.mumble' is known and matches the host + key. bast: Computing shared secret key. bast: Verifying server signature. bast: Waiting for NEWKEYS message. bast: Enabling incoming encryption/MAC/compression. bast: Send NEWKEYS, enable outgoing encryption/MAC/compression. bast: Sending request for user-authentication service. bast: Service accepted: ssh-userauth.bast: Trying empty user-authentic +ation request. input must be 8 bytes long at /usr/local/lib/perl5/site_perl/5.8.5/i68 +6-linux/Crypt/DES.pm line 57.

Any one have a clue for me?

Updated Steve_p - added code tags

Replies are listed 'Best First'.
Re: Net::SFTP problem, an odd twist.
by zentara (Cardinal) on Sep 28, 2004 at 16:22 UTC
    Here is an unverified clue. Someone asked this before, and I kept some notes. Here is what I have:
    don't use the "ssh_args" specifically. ) my %ssh_options = (options => "StrictHostKeyChecking no"); my %login = (user => $user, password => $pass, debug => 1, \%ssh_options ); ######################################################### #or my %ssh_options = ( StrictHostKeyChecking => "no" ); my %args = ( username => $user, password => $pass, debug => 1, ssh_args => (options => \%ssh_options) ); my $sftp = Net::SFTP->new($host, %args) Normally you should be able to fold this in, as so: my %args = ( username => $user, password => $pass, debug => 1, ssh_args => (options => { StrictHostKeyChecking => "no"} ) );

    I'm not really a human, but I play one on earth. flash japh
Re: Net::SFTP problem, an odd twist.
by jenfein (Initiate) on Nov 10, 2004 at 23:04 UTC
    I had the same issue. When the user and password are hard coded it works fine, if the values are pulled in from a configuration object it fails: 'input must be 8 bytes long at ...'

    This became a problem only after I switched from using a csv config file (that was parsed directly by the script) to an xml config file (that is parsed by a configuration module using XML::Parser).

    Now I cannot tell you why this works, and I would love it for someone to explain, but it does. I think for some reason the data cannot be padded correctly for Crypt::DES before this transformation.

    my $pass = $user_data->{password}; my $user = $user_data->{user}; my @pass = split '', $pass; my @user = split '', $user; $user = join '', @user; $pass = join '', @pass;