CentOS 7 防止暴力SSH登陆的两个措施

来源:互联网 发布:小米网络电视机 编辑:程序博客网 时间:2024/05/22 17:24

登陆系统(CentOS7),突然发现 67次登陆失败。
IP是 173.212.243.251,一查德国的!

措施一

  vi /etc/hosts.deny

添加以下内容

内容太多,放到了码云上,随时更新https://gitee.com/teamlet/hosts.deny

修改完毕,启动

 service xinetd restart

提示

Failed to issue method call: Unit xinetd.service failed to load: No such file or 

原因是缺少 xinetd ,安装xinetd

yum list |grep xinetdyum install xinetd.x86_64

安装完成后,将xinetd服务加入开机自启动

 systemctl enable xinetd.service

最后,启动服务:

 systemctl start xinetd(或service xinetd start

措施二

更改ssh登录失败验证次数

vi /etc/ssh/sshd_config

文件中有一个被注释掉的

 #MaxAuthTries  6

改为

  MaxAuthTries 3

重新启动服务

   systemctl restart sshd.service

通过

   systemctl status sshd.service 

查看最后一次登陆失败的IP、和登陆用户信息。

原创粉丝点击