All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Largent <jlargent@imagelinks.com>
To: Scott Taylor <scott@dctchambers.com>,
	linux-admin <linux-admin@vger.kernel.org>
Subject: Re: login attempts
Date: Thu, 10 Apr 2003 11:22:03 -0400	[thread overview]
Message-ID: <3E958C1B.3080508@imagelinks.com> (raw)
In-Reply-To: <5.1.1.6.0.20030410072747.00af4030@mustang>

Just a thought but how about a perl script that tails /var/log/secure
looking for failed login and then emails that to the SysAdmin.

#!/usr/bin/perl -w

use strict;
my $email = "sysadmin@work.bites"
my $logfile = "/var/log/secure";

open(LOG, $logfile);
for(;;) {
    while (<LOG>) {
       if( m/Failed/ ) {
          system("mailto $email -S \"Failed Login\" $_ ~.";
       }
    }
    sleep 15;
    seek(LOG, 0, 1);
}

Probley won't run but you get the idea.  You could replace
the system call with something else from a perl module.

Jeff

Scott Taylor wrote:
> Hello all,
> 
> I know I can find login attempts in the /var/log files.   Does anyone 
> know of  a way to tell ssh2d to send an email to the SysAdmin on failed 
> login attempts?
> 
> I tried with a script /bin/warn:
> #!/bin/bash
> mail -s "$LOGNAME" root <<EOF
> User $LOGNAME attempted to log in at:
> `date`
> From: $SSH_CLIENT
> EOF
> exit 0
> 
> which works fine from the command line, but not always (most of the 
> time) from a login attempt when the users shell is /bin/warn.
> 
> Output, when it works, looks like this:
> 
> Subject: scott
> 
> User scott attempted to log in at:
> Thu Apr 10 07:25:06 PDT 2003
> From: 192.168.99.65 3421 22
> 
> Cheers
> 
> Scott.
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

-- 
Jeff Largent                   ImageLinks, Inc.
Sr System Admin                Melbourne, Fl 32935
(321) 253-0011                 fax: (321) 253-5559


  parent reply	other threads:[~2003-04-10 15:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-10 14:36 login attempts Scott Taylor
2003-04-10 15:16 ` Adam T. Bowen
2003-04-10 15:22 ` Jeff Largent [this message]
2003-04-10 16:00   ` Scott Taylor
2003-04-10 19:01     ` Jay Goodman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E958C1B.3080508@imagelinks.com \
    --to=jlargent@imagelinks.com \
    --cc=linux-admin@vger.kernel.org \
    --cc=scott@dctchambers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.