实践1
每5分钟检查一次,如果发现通过ssh登录失败 次数超过10次,自动将此远程IP放入Tcp Wrapper的黑名单中予以禁止防问
[root@centos7 bin]#cat checkip.sh
#!/bin/bash
touch /etc/hosts.deny
lastb | awk ‘/ssh/{IP[$3]++}END{for(n in IP){if(IP[n]>2){system(“echo ‘sshd:’” n “:deny >> /etc/hosts.deny”)}}}’
grep ‘^#’ /etc/hosts.deny > /etc/hosts.deny.tmp
grep -v “^#” /etc/hosts.deny | sort -u >> /etc/hosts.deny.tmp
cat /etc/hosts.deny.tmp > /etc/hosts.deny
rm -f /etc/hosts.deny.tmp
[root@centos7 bin]#crontab -l
*/5 * * * * /bin/bash /root/bin/checkip.sh
实践2
配置magedu用户的sudo权限,允许magedu用户拥有root权限
vi /etc/sudoers
将这一样启用
%wheel ALL=(ALL) ALL
然后将mage账户加入wheel组即可
groupmems -g wheel -a mage
然后通过 sudo 即可在mage登陆界面下以root权限执行