--- lib/PXElator/ssh.pm 2009/08/27 18:57:46 312 +++ lib/PXElator/ssh.pm 2009/08/29 18:07:49 348 @@ -2,6 +2,7 @@ use Net::OpenSSH; use English; +use Data::Dump qw/dump/; my $id = 2; @@ -29,4 +30,28 @@ } +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|root\@$host:# $command
$out
|; + $html .= qq|
$err
| if $err; + } + + return $html; +} + +sub copy_id { + my $host = shift; + system 'sudo ssh-copy-id -i /root/.ssh/id_rsa.pub root@' . $host; +} + 1;