我对networkingpipe理很陌生,所以请注意我还没有那么有经验。
我有一个Ubuntu的根服务器与plesk面板。
昨天我的朋友和我注意到,我们的TS3的演讲质量非常糟糕。 我向服务器发送了一些ping消息,丢包非常高。 之后,我GOOGLE了一下,发现有一个auth.log
。 我下载并滚动了一下,然后我发现这个:
May 13 10:01:27 rs204941 sshd[9351]: input_userauth_request: invalid user student [preauth] May 13 10:01:27 rs204941 sshd[9351]: pam_unix(sshd:auth): check pass; user unknown May 13 10:01:27 rs204941 sshd[9351]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=112.220.198.102 May 13 10:01:29 rs204941 sshd[9351]: Failed password for invalid user student from 112.220.198.102 port 39806 ssh2 May 13 10:01:29 rs204941 sshd[9351]: Received disconnect from 112.220.198.102: 11: Bye Bye [preauth] May 13 10:01:31 rs204941 sshd[9353]: Invalid user student from 112.220.198.102
好像有人试图通过SSHlogin很多次。 我卷了一下,看到,这个人试图使用许多不同的用户名: student, tech, psi, news,...
数以百计的这些login显示在文件中。
我查看了我的数据中心网站的stream量统计数据。 只有每小时17MB。 我有一个100Mb的骨干,所以数据传输本身似乎不成问题。
目前我无法以任何方式访问服务器。
我的问题是:我怎么能再次访问,我怎么能抑制这个攻击,并防止以下攻击?
如何获得访问权限?
目前还不清楚为什么你不能访问你的帐户。
如果您的计算机受到攻击或高负载,则应与您的提供商讨论限制访问(IP限制)或使服务器脱机(断开与Internet的连接)。
您可能还需要您的提供商可以提供帮助的带外访问。
如果有人损害了您的服务器,您可能需要从备份中恢复或使用恢复映像。
如何防止攻击你的服务器,特别是SSH
不要让他们首先到达您的机器! 在到达主机之前,甚至在SSH级别,有很多方法可以阻止powershell尝试。
话虽如此,保护您的操作系统像fail2ban是一个好主意。 http://en.wikipedia.org/wiki/Fail2ban
Fail2ban类似于DenyHosts …但与DenyHosts关注于SSH不同,fail2ban可以configuration为监视任何将login尝试写入日志文件的服务,而不是使用/etc/hosts.deny来阻止IP地址/主机,fail2ban可以使用Netfilter / iptables和TCP Wrappers /etc/hosts.deny。
有几个重要的安全技术,您应该考虑帮助防止暴力login:
SSH:
应用:
我该如何抑制这种攻击,防止下面的攻击
通常我把默认的ssh端口从22更改为1122.这样可以防止很多bot的自动攻击,但是一个简单的端口扫描就可以检测到它。 无论如何:
vi /etc/ssh/sshd_config
并将端口22编辑到端口1122 ,但这还不够。
我使用log2iptables https://github.com/theMiddleBlue/log2iptables而不是Fail2ban,因为是一个简单的Bash脚本,用正则expression式parsing任何日志文件并执行iptables。 例如,当5个匹配发生时,log2iptables删除特定的IP地址。 这很酷,因为使用Telegram API,当他发现问题时,可以在我的手机上发送消息给我:)
希望这会有所帮助!
我把这些放在一起,每15分钟运行一次cronjob等等:
for z in `grep Invalid /var/log/auth.log | awk '{ print $NF }' | sort | uniq` do count1=`grep $z /etc/hosts.deny | wc -l` count2=`grep Invalid /var/log/auth.log | grep $z | wc -l` if [ $count1 -eq 0 -a $count2 -gt 10 ] ; then current=`egrep "^ssh" /etc/hosts.deny | sed 's/sshd[ :,]*//'` sudo cp /etc/hosts.deny.bak /etc/hosts.deny sudo chmod 666 /etc/hosts.deny if [ $current ] ; then echo "sshd : $current , $z" >> /etc/hosts.deny else echo "sshd : $z" >> /etc/hosts.deny fi sudo chmod 644 /etc/hosts.deny fi done
这是我的SSH攻击的替代解决scheme。 这个想法是closuresSSH守护进程,如果不使用。 没有开放的端口没有攻击。 你可以试试。 它是开源的https://github.com/indy99/nnet_port_guard