- Projects
- Computer security
- jQuery code
- qpsmtpd code
Steve Kemp's Homepage
|
Slaughter
|
Slaughter Examples
This example shows how to setup SSH authorized keys for a given user upon a number of systems. First of all we'll create the content on the webserver: mkdir -p /var/www/slaughter/ mkdir -p /var/www/slaughter/policies mkdir -p /var/www/slaughter/files Now we'll save the master authorized_keys file on the master, and locate it at /var/www/slaughter/files/global-keys. The next thing to do is to write the policy. We'll seperate this out and save the following as /var/www/slaughter/policies/default.policy: # # This is the policy downloaded and executed by all client nodes. # # Useful to keep this as a file which merely includes other files. # # # # Setup authorized-keys for "skx". # FetchPolicy skx-keys.policy ; Now we'll write /var/www/slaughter/policies/skx-keys.policy:
#
# Fetch the master authorized_keys file for the user skx and install
# it appropriately.
#
#
# Ensure the user exists.
#
if ( UserExists( User => "skx" ) )
{
# copy
FetchFile(
Source => "/global-keys",
Dest => "/home/skx/.ssh/authorized_keys2",
Owner => "skx",
Group => "skx",
Mode => "0600" );
}
With these files in place you should now be able to execute the slaughter client from any host which can reach your webserver: slaughter --keep --verbose --server example.com Here we've added "--keep" which will prevent the compiled script from being deleted, such that you can examine it. We've pointed it at the address of your server via the --server flag and finally ensured the output is more noisy than normal with --verbose. Below is some sample code to alert to "urgent@example.org" if any partition upon the disk is too full - which means that it is more than 80% in use.
#
# Ensure no mount-point is "too full".
#
foreach my $point ( Mounts() )
{
if ( PercentageUsed( path => $point ) > 80 )
{
Alert( To => 'urgent@example.org',
From => "root",
Subject => "$server is running out of space on $point",
Message => "This is a friendly warning." );
}
}
Save the previous code in /var/www/slaughter/policies/disk-check.policy, then add the following to policies/default.policy: # check on disk space FetchPolicy disk-check.policy; |