Perl Net::SSH2::SFTP Example
In my experiences, code has sometimes been better at explaining than documentation. Why did I do this? Because I didn't find it immediately when I searched for it... Cheers! Copy From PasteBin! #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Net::SSH2; use Net::SFTP; use Carp; use Fcntl; use Fcntl ':DEFAULT'; use constant SSH_USER => 'root'; use constant SSH_PASS => 'toor'; use constant SSH_HOST => 'localhost'; use constant SSH_PORT => 21; my ( $conn, $ssh, $sftp, $buf, $buffer, $len ); sub ssh_connect { my ( $ssh, $user, $host, $pass, $port ); ( $user, $pass, $host, $port ) = @_; $host ||= 'localhost'; $port ||= 22; $ssh = new Net::SSH2; $ssh->debug(1); $ssh->blocking(1); return 0 unless $ssh->connect($host . ':' . $port); print "[*] Connect OK!\n"; return 0 unless $ssh->auth( username => $user, password => $pass); print "[*] Auth OK!\n"; return $ssh; } sub