首页 期权学习期权知识正文

怎么查看服务器有没有被ssh远程暴力破解攻击and防御攻击

xiaojiucai 期权知识 2020-08-24 975 0

当你在公网上使用Linux服务器时,很有可能你的服务器正在遭受ssh暴力破解。

服务器导致内网瘫痪,而服务器是被黑客通过ssh暴力破解进入并植入了ARP攻击的病毒工具。

所以对于服务器最为基本的远程登录进行保护,往往反而是最重要的,也是最容易被新手们忽略的。

如何判断自己正在遭受ssh暴力破解

ssh登录服务器后使用lastb命令,命令会显示最近错误登录的日志,包括通过ssh服务错误登录的日志。

输入以下命令:

lastb | wc -l

我的服务器显示以下信息:

root@instance-20200410-1547:~# lastb | wc -l #wc -l是查看行数
9630

这个意思是被暴力攻击9630次,这是别人在程序字典化试密码

输入这条命令可以查看攻击信息:

lastb >> ssh.log

这样就可以打开ssh.log文件查看详细信息了

我的服务器被攻击信息显示如下(超级多):

root     ssh:notty    159.89.170.154   Sat Apr 11 11:38 - 11:38  (00:00)
globalfl ssh:notty    96.78.177.242    Sat Apr 11 11:38 - 11:38  (00:00)
admin    ssh:notty    87.249.164.79    Sat Apr 11 11:38 - 11:38  (00:00)
root     ssh:notty    119.6.225.19     Sat Apr 11 11:38 - 11:38  (00:00)
root     ssh:notty    142.93.174.47    Sat Apr 11 11:38 - 11:38  (00:00)
root     ssh:notty    139.199.75.110   Sat Apr 11 11:38 - 11:38  (00:00)
root     ssh:notty    134.209.115.206  Sat Apr 11 11:38 - 11:38  (00:00)
root     ssh:notty    46.101.94.224    Sat Apr 11 11:37 - 11:37  (00:00)
root     ssh:notty    182.61.37.144    Sat Apr 11 11:37 - 11:37  (00:00)
hacker   ssh:notty    175.107.198.23   Sat Apr 11 11:37 - 11:37  (00:00)
hacker   ssh:notty    175.107.198.23   Sat Apr 11 11:37 - 11:37  (00:00)
Test     ssh:notty    54.37.12.113     Sat Apr 11 11:37 - 11:37  (00:00)
Test     ssh:notty    54.37.12.113     Sat Apr 11 11:37 - 11:37  (00:00)
sherry   ssh:notty    165.227.203.162  Sat Apr 11 11:37 - 11:37  (00:00)
sherry   ssh:notty    165.227.203.162  Sat Apr 11 11:37 - 11:37  (00:00)
supervis ssh:notty    220.121.58.55    Sat Apr 11 11:37 - 11:37  (00:00)
supervis ssh:notty    220.121.58.55    Sat Apr 11 11:37 - 11:37  (00:00)
operator ssh:notty    142.93.174.47    Sat Apr 11 11:36 - 11:36  (00:00)
operator ssh:notty    142.93.174.47    Sat Apr 11 11:36 - 11:36  (00:00)
daniel   ssh:notty    54.38.42.63      Sat Apr 11 11:36 - 11:36  (00:00)
daniel   ssh:notty    54.38.42.63      Sat Apr 11 11:36 - 11:36  (00:00)
root     ssh:notty    134.209.115.206  Sat Apr 11 11:36 - 11:36  (00:00)
admin    ssh:notty    165.227.96.190   Sat Apr 11 11:36 - 11:36  (00:00)

那么如何防范这样的暴力破解呢,有以下三种方法:

方法一:修改远程登录端口

方法二:限制登录IP

方法三:使用非root用户登录

设置完后,重启sshd服务即可,基本就无大碍了,哈哈

(base) xialibing@ueack:~$ sudo -i #切换root用户
[sudo] xialibing 的密码: #输入当前用户密码
root@ueack:~# passwd user #user 是对应的用户名,这里用root

原文链接:https://www.qiquanji.com/post/139.html

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

微信扫码关注

更新实时通知

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

评论