in reply to passwordless SFTP works from cmd line, not from modules

Your mileage may vary but here's how I do it with Net::SFTP::Foreign:

#!/bin/env perl use strict; use warnings; use Net::SFTP::Foreign (); my ( $host, $user, $timeout ) = ( '<host>', '<user>', 30 ); # typicall +y from a subroutine call my $sftp = Net::SFTP::Foreign->new( host => $host, user => $user, timeout => $timeout, more => [ -i => "/some/path/to/$user/.ssh/id_dsa", # the path to your ke +y file -o => 'PreferredAuthentications=publickey', '-v', ], );