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_server, %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"; } } < #### 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-interactive. migas: Next method to try is publickey.