Tcp Wrapper和sudo权限

    技术2022-07-14  84

    1、编写脚本/root/bin/checkip.sh,每5分钟检查一次,如果发现通过ssh登录失败 次数超过10次,自动将此远程IP放入Tcp Wrapper的黑名单中予以禁止防问

    #! /bin/bash NUM=10 sleeptime=300 file=/etc/hosts.deny while ture;do cat /var/log/secure* | grep 'Failed password' | grep sshd | awk '{print $11}' |sort|uniq -c|while read COUNT IP ;do if [ "$COUNT" -ge "$NUM" ];then egrep -q ^sshd.*$IP $file [ $? -ne 0 ] && echo "sshd:$IP" >>$file fi done sleep $sleeptime done

    2、配置magedu用户的sudo权限,允许magedu用户拥有root权限

    visudo magedu ALL=(ALL) ALL
    Processed: 0.011, SQL: 9