0
点赞
收藏
分享

微信扫一扫

【远程服务器被试图破解】

技术只适用于干活 2022-04-29 阅读 48

今天登录远程服务器时,出现

There were 298 failed login attempts since the last successful login.

系统正在遭受暴力破解的风险

措施
1.首先拉黑试图破解你的密码的ip

>>> grep "Failed password for invalid user" /var/log/secure | awk '{print $13}' | sort | uniq -c | sort -nr

>>>> cat /var/log/secure |  grep "Failed password for invalid user" | awk '{print $13}' | sort | uniq -c | sort -n | tail -10 |awk '{print "sshd:"$2":deny"}' >> /etc/hosts.allow 

>>> tail -20 /etc/hosts.allow 

2.新增一个用户,将其加入root权限

>>> useradd xxx (xxx为你要新建的用户名)
>>> passwd xxx (xxx为你要新建的用户名)

3.为其添加root权限,使其可以通过输入密码的方式进入root权限

chmod u+x /etc/sudoers
vi /etc/sudoers

找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)

chmod u-w /etc/sudoers

4.修改SSHD配置,禁止root直接登录

>>> vi /etc/ssh/sshd_config

查找#PermitRootLogin yes,将前面的#去掉,“Yes”改为“No”,并保存文件
5.重启sshd

systemctl restart sshd.service

5.还可以设置密码验证,可以自己尝试===》

举报

相关推荐

0 条评论