in reply to Pass local bash script to remote host via SSH

Note that I can't run Net::SSH since I don't have access to additional modules

Yes, even you can use CPAN - Net::OpenSSH is a pure-Perl module with no dependencies, which means it can be simply copied over.

use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host); die "Couldn't establish SSH connection: ".$ssh->error if $ssh->error; my ($in, $pid) = $ssh->pipe_in('bash','-s') or die "pipe_in failed: ".$ssh->error; print $in <<'EOF'; # ... EOF close $in or die "close failed";

Replies are listed 'Best First'.
Re^2: Pass local bash script to remote host via SSH
by salva (Canon) on Jun 25, 2020 at 06:59 UTC
    Even shorter...
    use Net::OpenSSH; die "Couldn't establish SSH connection: ".$ssh->error if $ssh->error; $ssh->system({stdin_data => <<EOD}, 'bash', '-s') or die "command fail +ed: " . $ssh->error; # ... EOD