* login attempts
@ 2003-04-10 14:36 Scott Taylor
2003-04-10 15:16 ` Adam T. Bowen
2003-04-10 15:22 ` Jeff Largent
0 siblings, 2 replies; 5+ messages in thread
From: Scott Taylor @ 2003-04-10 14:36 UTC (permalink / raw)
To: linux-admin
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: login attempts
2003-04-10 14:36 login attempts Scott Taylor
@ 2003-04-10 15:16 ` Adam T. Bowen
2003-04-10 15:22 ` Jeff Largent
1 sibling, 0 replies; 5+ messages in thread
From: Adam T. Bowen @ 2003-04-10 15:16 UTC (permalink / raw)
To: Scott Taylor; +Cc: linux-admin
> 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?
[snip]
If you are using the TCP/IP daemon wrappers (libwrap) then you can put
this :
ALL : ALL : spawn (/bin/warn %a %A %d %n %N %u)
in your hosts.deny (usually in /etc). The expansions that you can pass to
your script are listed in man 5 hosts_access.
Cheers
Adam Bowen
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: login attempts
2003-04-10 14:36 login attempts Scott Taylor
2003-04-10 15:16 ` Adam T. Bowen
@ 2003-04-10 15:22 ` Jeff Largent
2003-04-10 16:00 ` Scott Taylor
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Largent @ 2003-04-10 15:22 UTC (permalink / raw)
To: Scott Taylor, linux-admin
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
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: login attempts
2003-04-10 15:22 ` Jeff Largent
@ 2003-04-10 16:00 ` Scott Taylor
2003-04-10 19:01 ` Jay Goodman
0 siblings, 1 reply; 5+ messages in thread
From: Scott Taylor @ 2003-04-10 16:00 UTC (permalink / raw)
To: linux-admin
At 08:22 AM 4/10/03, you wrote:
>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.
That's interesting Jeff,
for that matter I could pipe "tail -f /var/log/secure" through a sed 'n'
awk script, but maybe not. Although, I'm not really looking for failed
login or !failed login attempts only any login attempts.
Setting the shell to /bin/false works well to keep normal users out, also
setting the shell to my /bin/warn keeps them out, just doesn't always send
the mail.
Cheers.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: login attempts
2003-04-10 16:00 ` Scott Taylor
@ 2003-04-10 19:01 ` Jay Goodman
0 siblings, 0 replies; 5+ messages in thread
From: Jay Goodman @ 2003-04-10 19:01 UTC (permalink / raw)
To: scott; +Cc: linux-admin
I did something similar with and iptables log a while back.
If you decide to take this approach, (a bit better than the
the perl approach suggested earlier) when you're snooping on
a log file like that, make sure you use:
tail --follow=name /var/log/secure
Otherwise you maybe a bit confused why your not getting
any 'hits' after /var/log/secure has been rotated.
> At 08:22 AM 4/10/03, you wrote:
>>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.
>
> That's interesting Jeff,
>
> for that matter I could pipe "tail -f /var/log/secure" through a sed 'n'
> awk script, but maybe not. Although, I'm not really looking for failed
> login or !failed login attempts only any login attempts.
>
> Setting the shell to /bin/false works well to keep normal users out,
> also setting the shell to my /bin/warn keeps them out, just doesn't
> always send the mail.
>
> Cheers.
>
>
> -
> 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
--
caio,
jay
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-04-10 19:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-10 14:36 login attempts Scott Taylor
2003-04-10 15:16 ` Adam T. Bowen
2003-04-10 15:22 ` Jeff Largent
2003-04-10 16:00 ` Scott Taylor
2003-04-10 19:01 ` Jay Goodman
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.