Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joet3ch/1332596 to your computer and use it in GitHub Desktop.
Save joet3ch/1332596 to your computer and use it in GitHub Desktop.
use File::Tail;
my @errors = (’Bad protocol version identification’,'Failed password’,'Did not receive identification string’);
my $line;
my $file = File::Tail->new(”/var/log/auth.log”);
while (defined($line=$file->read)) {
if ($line =~ /$errors[0]|$errors[1]|$errors[2]/) {
open(SSHALERT, “>/tmp/sshalert.txt”);
print SSHALERT “$line”;
system (’mplayer some_loud_audio_file.mp3′);
system (’mutt -s ALERT-SSH -c someuser@somedomain.com < /tmp/sshalert.txt’);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment