1、编写脚本/root/bin/checkip.sh,每5分钟检查一次,如果发现通过ssh登录失败 次数超过10次,自动将此远程IP放入Tcp Wrapper的黑名单中予以禁止防问
#!/bin/bash
sleeptime=300
num=10
file=/etc/hosts.deny
while true;do
lastb | grep ssh|awk '{print $3}'|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