▲就业班和全程班的小伙伴看这里:(学习老王视频的作业第21-22节)
1、编写脚本/root/bin/checkip.sh,每5分钟检查一次,如果发现通过ssh登录失败 次数超过10次,自动将此远程IP放入Tcp Wrapper的黑名单中予以禁止防问
[root@centos7~]#cat /root/bin/checkip.sh
#!/bin/bash
while true;do
lastb |awk '! /^btmp|^$/{ip[$3]++}END{for(i in ip){if(ip[i]>=10){system("echo sshd:"i">> /etc/hosts.deny")}}}'
sleep 5m
done
2、配置magedu用户的sudo权限,允许magedu用户拥有root权限
2.1 方法一:将magedu用户加入wheel组
[root@centos7 ~]#groupmems -g wheel -a magedu
[root@centos7 ~]#su - magedu
[magedu@centos7 ~]$ sudo cat /etc/shadow
[sudo] password for magedu:
root:$6$S2b6NrGJA30/::0:99999:7:::
bin:*:17834:0:99999:7:::
daemon:*:17834:0:99999:7:::
…………
2.2 方法二:修改 /etc/sudoers 文件
[root@centos7 ~]#visudo
magedu ALL=(root) ALL
[root@centos7 ~]#su - magedu
[magedu@centos7 ~]$sudo cat /etc/shadow
root:$6$S2b6NrGJA30/::0:99999:7:::
bin:*:17834:0:99999:7:::
……
2.3 方法三:创建 /etc/sudoers.d/magedu 文件
[root@centos7 ~]#visudo -f /etc/sudoers.d/magedu
magedu ALL=(root) ALL
[root@centos7 ~]#su - magedu
[magedu@centos7 ~]$sudo cat /etc/shadow
root:$6$S2b6NrGJA30/::0:99999:7:::
bin:*:17834:0:99999:7:::
……