Changeset 7a8d667 for fedkit


Ignore:
Timestamp:
Sep 19, 2008 6:25:54 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
01073f7
Parents:
9d207bd
Message:

reconfigure sshd_config explicitly

Location:
fedkit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedkit/fed-tun.pl

    r9d207bd r7a8d667  
    2121use Sys::Hostname;
    2222use IO::File;
     23use File::Copy;
    2324
    2425my $IFCONFIG = "/sbin/ifconfig";
     
    2930my $ROUTE_GET = "/sbin/route get";  # XXX:  works on FreeBSD, but should
    3031                                    #       should be 'ip route get' for Linux
     32my $sshd_config = "/etc/ssh/sshd_config";    # Probably should be a param
    3133
    3234# Ports that are forwarded between testbeds
     
    7173my $remote_config_file;         # Config file for the other side
    7274
    73 if ($#ARGV != 0 && !getopts('df:r', \%opts)) {
     75if ($#ARGV != 0 && !getopts('df:rn', \%opts)) {
    7476    die "$usage";
    7577}
     
    132134    }
    133135
    134     @ssh_port_fwds = () if ($opts{'type'} eq 'experiment');
     136    # -n just starts the ssh tap tunnel
     137    @ssh_port_fwds = () if ($opts{'type'} eq 'experiment' || $opts{'n'});
    135138
    136139    print "ssh_port_fwds = ", join("\n",@ssh_port_fwds), "\n" if ($debug);
    137140}
     141
     142# Both sides need to have GatewayPorts to be set.  Copy the existing
     143# sshd_config, making sure GatewayPorts is set to yes, replace the original,
     144# and restart sshd.
     145my $ports_on = 0;
     146
     147my $conf = new IO::File($sshd_config) || die "Can't open $sshd_config: $!\n";
     148my $new_conf = new IO::File(">/tmp/sshd_config") ||
     149    die "Can't open new ssh_config: $!\n";
     150
     151while(<$conf>) {
     152    s/^\s*GatewayPorts.*/GatewayPorts yes/ && do {
     153        print $new_conf $_ unless $ports_on++;
     154        next;
     155    };
     156    print $new_conf $_;
     157}
     158print $new_conf "GatewayPorts yes\n" unless $ports_on;
     159$conf->close();
     160$new_conf->close();
     161
     162copy("/tmp/sshd_config", $sshd_config) ||
     163    die "Cannot replace $sshd_config: $!\n";
     164
     165system("/etc/rc.d/sshd restart");
    138166
    139167# Need these to make the Ethernet tap and bridge to work...
  • fedkit/fed-tun.ucb.pl

    r9d207bd r7a8d667  
    3030my $ROUTE_GET = "/sbin/route get";  # XXX:  works on FreeBSD, but should
    3131                                    #       should be 'ip route get' for Linux
     32my $sshd_config = "/etc/ssh/sshd_config";    # Probably should be a param
    3233
    3334# Ports that are forwarded between testbeds
     
    131132}
    132133
     134# Both sides need to have GatewayPorts to be set.  Copy the existing
     135# sshd_config, making sure GatewayPorts is set to yes, replace the original,
     136# and restart sshd.
     137my $ports_on = 0;
     138
     139my $conf = new IO::File($sshd_config) || die "Can't open $sshd_config: $!\n";
     140my $new_conf = new IO::File(">/tmp/sshd_config") ||
     141    die "Can't open new ssh_config: $!\n";
     142
     143while(<$conf>) {
     144    s/^\s*GatewayPorts.*/GatewayPorts yes/ && do {
     145        print $new_conf $_ unless $ports_on++;
     146        next;
     147    };
     148    print $new_conf $_;
     149}
     150print $new_conf "GatewayPorts yes\n" unless $ports_on;
     151$conf->close();
     152$new_conf->close();
     153
     154copy("/tmp/sshd_config", $sshd_config) ||
     155    die "Cannot replace $sshd_config: $!\n";
     156
     157system("/etc/rc.d/sshd restart");
     158
     159
    133160# Need these to make the Ethernet tap and bridge to work...
    134161
Note: See TracChangeset for help on using the changeset viewer.