#!/usr/bin/perl
# clearcfkey, Boone, 09/22/08
# Forget old cfengine key for this machine
#
# Modifications:
# 09/22/08 Boone      Initial coding
# End Modifications

# Misc variables

	$sshcmd = "/usr/bin/ssh";
        @sshargs =
        (
                "-o",
                "BatchMode=yes",
                "-o",
                "PreferredAuthentications=publickey",
                "-o",
                "StrictHostKeyChecking=no",
                "-i",
                "/etc/ssh/id_Rmrsh_rsa",
                "-l",
                "Rmrsh",
		"faihost.matrix.msu.edu"
        );
	$sshargs = join(" ", @sshargs);

# Get list of IPs

	open(CMD, "/usr/sbin/showipaddr |");
	@ips = <CMD>;
	close(CMD);

# Do the change

	foreach $ip (@ips)
	{
		chop($ip);
		$keypath = "/var/lib/cfengine2/ppkeys/root-" . $ip . ".pub";
		exec($sshcmd, @sshargs, "test", "-f", $keypath, "&&", "rm", $keypath);
	}

# Done

	exit(0);
