server::setup_from_dev will take configuration from existing device
[pxelator] / lib / PXElator / ssh.pm
1 package ssh;
2
3 use Net::OpenSSH;
4
5 my $id = 2;
6
7 sub ethernet_bridge_to {
8         my $host = shift;
9
10         warn "# reset local IP address";
11         system "ifconfig virtual 172.16.10.$id";
12
13         warn "# connect to $host";
14         my $ssh = Net::OpenSSH->new( $host,
15                 master_opts => [ -w => "$id:$id", -o => 'Tunnel=ethernet' ],
16         );
17
18         foreach my $command ( "ifconfig tap$id up", "brctl addif virtual tap$id" ) {
19                 warn "# $command";
20                 system $command;
21                 $ssh->system( $command ) or die "$command ", $ssh->error;
22         }
23
24         warn "press enter to close tunnel to $host from $id";
25         <STDIN>;
26
27 }
28
29 1;