#!/usr/bin/perl use Net::SFTP; use Net::SSH2; $remote = "x" $local_ssh2 = "ssh2"; $local_sftp = "sftp"; my $ssh2 = Net::SSH2->new(); $ssh2->connect($server) or die $!; if ($ssh2->auth_password($username,$password)) { my $sftp = $ssh2->sftp(); my %stat = $sftp->stat($remote); $filesize_ftp = $stat{size}; print "Filesize von $remote ist $filesize_ftp\n\n"; # => das geht schnell #$ssh2->scp_get($remote,$local_ssh2); # => der Teil geht nicht, erzeugte leere Datei open (OUTPUT, "> $local_ssh2"); # => die langsame Alternative aus der Doku cpan my $fh = $sftp->open($remote) or die; print OUTPUT $_ while <$fh>; } $ssh2->disconnect(); # make our connection, Modul Net::SFTP print "\n\n\nConnecting to $server mit $username und $password ... \n\n"; %args = ("user" => $username, "password" => $password); my $sftp = Net::SFTP->new($server, %args); $sftp->get($remote, $local_sftp); print "Finished\n";