#!/usr/bin/perl use strict; use warnings; use 5.024; use utf8; use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect('servana') or $ssh2->die_with_error; # $ssh2->check_hostkey( 'ask', "T:/.ssh/known_hosts" ) or $ssh2->die_with_error; $ssh2->auth_password ( "test", "test" ) or $ssh2->die_with_error; # $ssh2->auth_publickey( 'test', "T:/.ssh/id_rsa.pub", "T:/.ssh/id_rsa", "test42" ) or $ssh2->die_with_error; my $sftp = $ssh2->sftp() or $ssh2->die_with_error; my $fh = $sftp->open('/home/test/.bashrc') or $sftp->die_with_error; print while <$fh>;