... my $ssh = Net::OpenSSH->new(external_master => 1, ctl_path => $ctl_path); my $sftp = $ssh->sftp // $ssh->die_on_error("Unable to create SFTP session"); # at this point $sftp is a regular Net::SFTP::Foreign object you can use in any way you like. ...