可疑 IP 尝试连接服务器

可疑 IP 尝试连接服务器

我收到消息“ suspicious ip [x.x.x.x] attempt to connect server 我必须针对此问题采取什么措施?”受影响的服务器是 Ubuntu 14.04 服务器,并且具有ufw公共 IP。

ufw日志:

Nov  3 12:12:55  kernel: [358619.800870] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=37.139.191.161 DST=10.0.0.12 LEN=44 TOS=0x00 PREC=0x00 TTL=44 ID=8329 PROTO=TCP SPT=43730 DPT=23 WINDOW=23100 RES=0x00 SYN URGP=0
Nov  3 12:14:08  kernel: [358692.822316] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=122.114.182.64 DST=10.0.0.12 LEN=40 TOS=0x00 PREC=0x00 TTL=233 ID=48132 PROTO=TCP SPT=54910 DPT=1433 WINDOW=1024 RES=0x00 SYN URGP=0
Nov  3 12:14:11  kernel: [358696.027769] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=89.248.172.16 DST=10.0.0.12 LEN=40 TOS=0x00 PREC=0x00 TTL=113 ID=52590 PROTO=TCP SPT=46640 DPT=8009 WINDOW=62657 RES=0x00 SYN URGP=0
Nov  3 12:14:43  kernel: [358727.590448] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=123.249.3.172 DST=10.0.0.12 LEN=40 TOS=0x00 PREC=0x00 TTL=107 ID=256 PROTO=TCP SPT=37365 DPT=8080 WINDOW=16384 RES=0x00 SYN URGP=0
Nov  3 12:14:45  kernel: [358729.683181] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=218.29.142.44 DST=10.0.0.12 LEN=44 TOS=0x00 PREC=0x00 TTL=234 ID=44905 PROTO=TCP SPT=50889 DPT=1433 WINDOW=1024 RES=0x00 SYN URGP=0
Nov  3 12:16:01  kernel: [358806.142162] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=176.109.226.160 DST=10.0.0.12 LEN=44 TOS=0x00 PREC=0x00 TTL=47 ID=8329 PROTO=TCP SPT=43730 DPT=23 WINDOW=23100 RES=0x00 SYN URGP=0
Nov  3 12:16:24  kernel: [358829.214991] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=212.142.159.191 DST=10.0.0.12 LEN=40 TOS=0x00 PREC=0x00 TTL=50 ID=35874 PROTO=TCP SPT=13461 DPT=23 WINDOW=9861 RES=0x00 SYN URGP=0
Nov  3 12:17:16  kernel: [358881.046988] [UFW BLOCK] IN=eth0 OUT= MAC=08:24:14:33:18:01:08:00 SRC=45.55.29.228 DST=10.0.0.12 LEN=40 TOS=0x00 PREC=0x00 TTL=238 ID=54321 PROTO=TCP SPT=57539 DPT=3306 WINDOW=65535 RES=0x00 SYN URGP=0

认证日志

/var/log$ tailf auth.log

Nov  3 12:47:55  sshd[10102]: Failed password for root from 58.218.198.146 port 50077 ssh2
Nov  3 12:48:00  sshd[10102]: message repeated 2 times: [ Failed password for root from 58.218.198.146 port 50077 ssh2]
Nov  3 12:48:01  sshd[10102]: Received disconnect from 58.218.198.146: 11:  [preauth]
Nov  3 12:48:01  sshd[10102]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.146  user=root
Nov  3 12:48:17  sshd[10104]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.146  user=root
Nov  3 12:48:19  sshd[10104]: Failed password for root from 58.218.198.146 port 27919 ssh2
Nov  3 12:48:24  sshd[10104]: message repeated 2 times: [ Failed password for root from 58.218.198.146 port 27919 ssh2]
Nov  3 12:48:24  sshd[10104]: Received disconnect from 58.218.198.146: 11:  [preauth]
Nov  3 12:48:24  sshd[10104]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.146  user=root
Nov  3 12:48:37  sshd[10108]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.146  user=root
Nov  3 12:48:39  sshd[10108]: Failed password for root from 58.218.198.146 port 43229 ssh2
Nov  3 12:48:43  sshd[10108]: message repeated 2 times: [ Failed password for root from 58.218.198.146 port 43229 ssh2]
Nov  3 12:48:43  sshd[10108]: Received disconnect from 58.218.198.146: 11:  [preauth]
Nov  3 12:48:43  sshd[10108]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=58.218.198.146  user=root

答案1

这些都是自动尝试破解你的 ssh 服务器的行为,非常常见。

我认为您需要采取的最重要的行动是:

  1. 仅允许通过密钥进行 ssh 登录,禁用密码。

  2. 不允许root登录。

您不需要安装任何额外的服务,您可以使用 iptables 来解决这个问题。

首先安装 iptables-persistent

sudo apt-get install iptables-persistent

然后

sudo iptables -A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -m recent --set --name SSH --rsource

sudo iptables -A INPUT -m recent --update --rchedk --seconds 600 --hitcount 8 --rttl --name SSH --rsource -j --reject-with icmp-host-prohibited 

sudo iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT

“--hit count” 是新连接的数量。请记住,每个新连接都会提供多次输入密码的机会。如果您使用 scp,请使用更高的 hitcount,因为每个文件都将是一个新的 ssh 会话。

“--seconds” IP 地址被列入黑名单的时间。10 分钟通常足以阻止大多数“脚本小子”。

如需更多信息/建议,请参阅http://bodhizazen.com/Tutorials/SSH_security

相关内容