针对 Azure 中 Linux VM 的黑客攻击

针对 Azure 中 Linux VM 的黑客攻击

我遇到了一个非常奇怪的情况。我刚刚创建了一个新的虚拟机,它只运行了 30 分钟,然后我看到了一个奇怪的活动auth.log

Aug 10 16:52:35 ubuntu sshd[23186]: Failed password for root from 121.18.238.29 port 59064 ssh2
Aug 10 16:52:40 ubuntu sshd[23186]: message repeated 2 times: [ Failed password for root from 121.18.238.29 port 59064 ssh2]
Aug 10 16:52:40 ubuntu sshd[23186]: Received disconnect from 121.18.238.29 port 59064:11:  [preauth]
Aug 10 16:52:40 ubuntu sshd[23186]: Disconnected from 121.18.238.29 port 59064 [preauth]
Aug 10 16:52:40 ubuntu sshd[23186]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=121.18.238.29  user=root
Aug 10 16:52:41 ubuntu sshd[23188]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=121.18.238.20  user=root
Aug 10 16:52:43 ubuntu sshd[23190]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=121.18.238.29  user=root
Aug 10 16:52:43 ubuntu sshd[23188]: Failed password for root from 121.18.238.20 port 56100 ssh2
Aug 10 16:52:45 ubuntu sshd[23190]: Failed password for root from 121.18.238.29 port 39684 ssh2
Aug 10 16:52:47 ubuntu sshd[23188]: Failed password for root from 121.18.238.20 port 56100 ssh2
Aug 10 16:52:47 ubuntu sshd[23190]: Failed password for root from 121.18.238.29 port 39684 ssh2
Aug 10 16:52:50 ubuntu sshd[23190]: Failed password for root from 121.18.238.29 port 39684 ssh2
Aug 10 16:52:50 ubuntu sshd[23188]: Failed password for root from 121.18.238.20 port 56100 ssh2
Aug 10 16:52:50 ubuntu sshd[23190]: Received disconnect from 121.18.238.29 port 39684:11:  [preauth]
Aug 10 16:52:50 ubuntu sshd[23190]: Disconnected from 121.18.238.29 port 39684 [preauth]
Aug 10 16:52:50 ubuntu sshd[23190]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=121.18.238.29  user=root
Aug 10 16:52:50 ubuntu sshd[23188]: Received disconnect from 121.18.238.20 port 56100:11:  [preauth]
Aug 10 16:52:50 ubuntu sshd[23188]: Disconnected from 121.18.238.20 port 56100 [preauth]
Aug 10 16:52:50 ubuntu sshd[23188]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=121.18.238.20  user=root
Aug 10 16:52:52 ubuntu sshd[23196]: Did not receive identification string from 13.64.88.11
Aug 10 16:52:53 ubuntu sshd[23194]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=121.18.238.20  user=root

我只是对虚拟机进行了更新/升级并添加了新adm用户。我怎么会这么快受到攻击?

答案1

这是很常见的情况。“黑客”会使用 Azure IP 列表,并尝试暴力破解 SSH 以访问您的服务器。如上面的日志所示,只出现了失败。您的 IP 很可能是从另一个 Azure VM 取消分配的。

我在线设置的几乎每个服务器都存在这个问题。我建议您采取两项措施。

  1. 将 SSH 端口更改为其他端口,这大大降低了你受到攻击的机会。

  2. 安装失败2ban。这将允许您在一定时间内禁止 IP,或者在进行 x 次身份验证后永久禁止 IP。

另外,仅使用密钥 SSH 可以进一步提高安全性。

答案2

您尚未遭到黑客攻击,但有人正试图入侵。

你应该实施失败禁止在一定次数的登录尝试失败后暂时阻止 IP。

您的情况没有任何理由使“新 VM 或管理员用户”变得有意义。攻击针对的是帐户root,并且 VM 位于分配给 VM 之前就存在的 IP 地址上。有人执行了端口扫描,注意到端口已启动,然后尝试了分布式暴力攻击。IP 地址的前受让人可能也拥有 SSH 服务,因此您可能正在遭受针对前受让人的攻击。我们无法判断。

答案3

这种情况很常见,不幸的是会经常发生。这些尝试只是机器人随机探测整个 IP 类,而你的尝试是在你部署虚拟机 30 分钟后发生的。如果你觉得麻烦,我建议安装 fail2ban。

答案4

当你合法登录到远程主机时,你应该使用 ssh 密钥来避免使用密码...一旦这是真的,然后禁用允许在该远程主机上使用密码...在你的远程主机上编辑

vi /etc/ssh/sshd_config

# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
PasswordAuthentication no

然后在远程主机上通过发出以下命令弹出其 ssh 守护进程:

sudo service sshd restart

(除非您使用密码登录,否则它不会终止您的 ssh 登录会话)

此更改将预先阻止所有使用密码的登录尝试,因此这些消息将停止

Failed password for root from 182.100.67.173 port 41144 ssh2

相关内容