Created
August 16, 2018 11:37
-
-
Save ddmitov/1527f9fca9fb954fed57d550571b4776 to your computer and use it in GitHub Desktop.
Execute remote commands using Perl5, Net::OpenSSH and a private key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Net::OpenSSH; | |
my $ssh = Net::OpenSSH->new('[email protected]', key_path => '/path/to/private_key'); | |
$ssh->error and die "Couldn't establish SSH connection: ".$ssh->error; | |
my ($stdin, $stdout, $stderr, $pid) = $ssh->open3("ls -l"); | |
my @output = <$stdout>; | |
print @output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment