linux编程 - Linux如何查看每日失败的登录记录?
PHP中文网
PHP中文网 2017-04-17 14:51:53
0
1
432
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
小葫芦

Can you post a log of failed login? This can be achieved using cat, grep, and awk commands. I don’t know the specific format and cannot correctly write the matching shell


2016-5-14 10:01:36 Add a script.

Create a log_login_by_ip.sh file with the following content:

#!/bin/bash
clear
if [[ $# -eq 0 ]]
then
    week=(`env LANG=en_US.UTF-8 date '+%a'`)
    month=(`env LANG=en_US.UTF-8 date '+%b'`)
    day=(`env LANG=en_US.UTF-8 date '+%d' | grep -ioP "[1-9]+"`)

    # test data
    #week=Fri
    #month=May
    #day=13
   lastb -a|grep -iE $week"[ ]+"$month"[ ]+"$day|awk  -F"[ ]+" '{print $NF}'|sort|uniq
fi

Output result:

Note:
If you no longer want to clear the screen after executing this script, please block or delete the clear command.
Execute command:

sh ./log_login_by_ip.sh
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!