use Net::OpenSSH;
use English;
+use Data::Dump qw/dump/;
my $id = 2;
}
+sub shell {
+ my $host = shift;
+
+ my $ssh = Net::OpenSSH->new( $host );
+
+ my $html;
+
+ foreach my $command ( @_ ) {
+ warn "root\@$host:# $command\n";
+ my ($out,$err) = $ssh->capture2( $command ) or die "$command ", $ssh->error;
+ warn "$out\n$err";
+
+ $html .= qq|<tt style="color: grey">root\@$host:# <b>$command</b></tt><pre>$out</pre>|;
+ $html .= qq|<pre style="color: red">$err</pre>| if $err;
+ }
+
+ return $html;
+}
+
+sub copy_id {
+ my $host = shift;
+ system 'sudo ssh-copy-id -i /root/.ssh/id_rsa.pub root@' . $host;
+}
+
1;