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

Hi All,

It's me again... the backup guy... I'm developing the cross platfrom simplebackup program (http://migas.kicks-ass.org/index.php?pag=en.myapps&subpag=simplebackup)

Right now i'm adding the final new feature secure ftp...

Under windows i have made it work by using the putty psftp.exe program.

Under unix i want to use the perl modules Net::SFTP and Net::SSH2... if the user has Net::SSH2 then use that module if not use Net::SFTP.


My actual question... Net::SFTP DOES NOT WORK... it is unable to use username/password authentication
here is the code...
my $special_error_flag = 0; $network_debug_level_real = 2; $network_username = "root"; $password = "root password"; my %ssh_config = ( port => $network_server_port, ); my %sftp_config = ( user => $network_username, password => $network_password, debug => $network_debug_level_real +, ssh_args => \%ssh_config, ); eval { $$network_connection_p = Net::SFTP->new($network_se +rver, %sftp_config ) or $special_error_flag = 1; }; if ( $@ ) { # sftp connection failure $$network_connection_p = (); print "Connection failed\n"; } print "special_error_flag $special_error_flag\n"; if ( $special_error_flag == 0 ) { print "login"; my @listings = $$network_connection_p->ls("/root" +); foreach my $teste ( @listings ) { print "teste $teste\n"; } } <

here is the log
migas: Reading configuration data /root/.ssh/config migas: Reading configuration data /etc/ssh_config migas: Allocated local port 1023. migas: Connecting to localhost, port 443. migas: Remote version string: SSH-1.99-OpenSSH_3.9p1 migas: Remote protocol version 1.99, remote software version OpenSSH_3 +.9p1 migas: Net::SSH::Perl Version 1.30, protocol version 2.0. migas: No compat match: OpenSSH_3.9p1. migas: Connection established. migas: Sent key-exchange init (KEXINIT), wait response. migas: Algorithms, c->s: 3des-cbc hmac-sha1 none migas: Algorithms, s->c: 3des-cbc hmac-sha1 none migas: Entering Diffie-Hellman Group 1 key exchange. migas: Sent DH public key, waiting for reply. migas: Received host key, type 'ssh-dss'. migas: Host 'localhost' is known and matches the host key. migas: Computing shared secret key. migas: Verifying server signature. migas: Waiting for NEWKEYS message. migas: Enabling incoming encryption/MAC/compression. migas: Send NEWKEYS, enable outgoing encryption/MAC/compression. migas: Sending request for user-authentication service. migas: Service accepted: ssh-userauth. migas: Trying empty user-authentication request. migas: Authentication methods that can continue: publickey,keyboard-in +teractive. migas: Next method to try is publickey.

Does anyone has a clue ? thanks in advanded !
PS: Hope you try out my simplebackup program, it's open source.

Migas - Miguel

Replies are listed 'Best First'.
Re: Net::SFTP HELP....
by neilwatson (Priest) on Oct 03, 2006 at 17:19 UTC
    Are you able to initiate a manual ssh connection? Is anyone else conserned about a program that uses SSH as root and stores the root password in plain text?

    Neil Watson
    watson-wilson.ca

      Hi Neil Watson, I'm not worried about the root user thing... this code is sample code and is intended to be a test candidate !

      I have tested with other ssh users to the same result... and yes the manual ssh connections work...

      PS: i'm not a perl or unix newbie... not a guru but not a newbie ;)

      Any way thanks for your reply !
      Migas - Miguel