source: fedkit/port_forward.pl @ bc0b21b

axis_examplecompt_changesinfo-opsversion-3.01version-3.02
Last change on this file since bc0b21b was 97edf0d, checked in by Ted Faber <faber@…>, 15 years ago

finish rename

  • Property mode set to 100644
File size: 2.8 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4
5use gateway_lib;
6
7use IO::File;
8
9use Getopt::Long;
10
11my $ssh_pubkey;
12my $ssh_privkey;
13my $tunnelip;
14my $peer;
15my @ports;
16my $fedkit_dir= "/usr/local/federation";
17my $perl = "/usr/bin/perl";
18my $iface_file;
19my $ssh = "/usr/bin/ssh";
20my $use_file;
21my $ssh_port=22;
22my %opts = (
23    'ssh_pubkey=s' => \$ssh_pubkey,
24    'ssh_privkey=s' => \$ssh_privkey,
25    'tunnelip' => \$tunnelip,
26    'peer=s' => \$peer,
27    'port=s', \@ports,
28    'fedkit=s' => \$fedkit_dir,
29    'perl=s' => \$perl,
30    'ssh=s' => \$ssh,
31    'ssh_port=s' => \$ssh_port,
32    'use_file' => \$use_file,
33);
34
35exit(20) unless GetOptions(%opts);
36
37gateway_lib::read_config(gateway_lib::config_filename(), \%opts)
38    if $use_file;
39
40my $tunnelparam = $tunnelip ? '--tunnelip' : '';
41
42system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl --peer=$peer " .
43    "--ssh_pubkey=$ssh_pubkey $tunnelparam");
44exit(20) if $?;
45
46foreach my $p (@ports) {
47    my ($type, $port, $host, $eport) = split(":", $p);
48    $eport = $port unless $eport;
49    my $fopt =  ($type eq 'local'  ? "-L" : "-R") . " :$port:$host:$eport";
50    my $cmd = "$ssh -N $fopt -p $ssh_port -o \"StrictHostKeyChecking no\" " .
51        "-i $ssh_privkey $peer &";
52    system($cmd);
53    die if $?;
54}
55
56exit(0);
57
58=pod
59
60=head1 NAME
61
62B<port_forward.pl> - Do ssh service port forwarding.
63
64=head1 OPTIONS
65
66=over 8
67
68=item B<fedkit=>I<install_dir>
69
70Directory in which this software is installed.  Generally not needed.
71
72=item B<peer=>I<hostname>
73
74The other gateway providing forwarding.
75
76=item B<perl=>I<perl_binary>
77 
78Location of the perl binary.  Usually unneeded.
79
80=item B<port=>I<port_spec>
81
82Forward the given port.  Each port is given as type:lport:host:rport where
83type can be "local" or "remote".  These correspont to B<-L> and B<-R> ssh
84port forwarding, respectively.  The remaining parameters are exactly as for
85those parameters to ssh.
86
87=item B<ssh=>I<ssh_binary>
88
89The pathname of the ssh binary.  Unusally unnecessary.
90
91=item B<ssh_pubkey=>I<keyfile>
92
93A public to install as authorized.
94
95=item B<ssh_privkey=>I<identity_file>
96
97The identity to use for remote access
98
99=item B<tunnelip>
100
101True if the testbed uses the DETER tunnelip extension to provide external
102connectivity information
103
104=item B<use_file>
105
106If given read additional parameters from the file in
107/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
108current testbed project and experiment and the hostname is before the first
109dot.  The file is option: value.
110
111
112=back
113
114=head1 SYNOPSIS
115
116In addition to providing the key initialization and DETER routing setup for a
117gateway without external access as B<active_config.pl> does, B<forward_port.pl>
118forwards the given ports using ssh.  B<forward_port.pl> does not establish low
119level connectivity tunnels.
120
121
122=head1 AUTHORS
123
124Ted Faber <faber@isi.edu>
125
126=cut
Note: See TracBrowser for help on using the repository browser.