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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.