8 use Data::Dump qw/dump/;
13 my $id_rsa = '/root/.ssh/id_rsa';
17 my $ssh = client::ip_path( $ip, 'ssh' );
19 my $id = $id_rsa . '.pub';
20 my $cmd = "sudo ssh-copy-id -i $id root\@$ip";
27 sub ethernet_bridge_to {
30 die "you need to run this as root\n" unless $UID == 0;
34 warn "# reset local IP address";
35 system "ifconfig virtual 172.16.10.$id";
37 warn "# connect to $ip";
38 my $ssh = Net::OpenSSH->new( $ip,
39 master_opts => [ -i => $id_rsa, -w => "$id:$id", -o => 'Tunnel=ethernet' ],
42 foreach my $command ( "ifconfig tap$id up", "brctl addif virtual tap$id" ) {
45 $ssh->system( $command ) or die "$command ", $ssh->error;
48 warn "press enter to close tunnel to $ip from $id";
51 system "ifconfig virtual 172.16.10.1";
60 warn "# ssh $ip -i $id_rsa";
61 my $ssh = Net::OpenSSH->new( $ip,
62 master_opts => [ -i => $id_rsa ],
68 foreach my $command ( @_ ) {
69 warn "root\@$ip:# $command\n";
70 my ($out,$err) = $ssh->capture2( $command ) or die "$command ", $ssh->error;
73 store::audit( $ip, $command, { ip => $ip, command => $command, out => $out, err => $err } );
75 $html .= qq|<tt style="color: grey">root\@$ip:# <b>$command</b></tt><pre>$out</pre>|;
76 $html .= qq|<pre style="color: red">$err</pre>| if $err;