如何处理服务器被暴力破解
事情起因
工作日临近下班点,同事反馈说公司SAAS产品无法访问了。
what the fuck!
我使用终端工具连接服务器发现无法连接,去ECS控制台查看内存占用25%,由于没有安装监控Agent,其他的指标看不到。
我想使用页面上的功能,直接连接数据库,发现也是无法登录。
只能进行重启。
重启后我查看日志发现,一直有不同的IP尝试登录我的服务器。
sudo tail -f /var/log/secure
[root@mgchdxuxi /]# sudo tail -f /var/log/secure
Mar 10 10:12:53 mgchdxuxi sshd[8323]: pam_unix(sshd:auth): check pass; user unknown
Mar 10 10:12:53 mgchdxuxi sshd[8323]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=14.103.113.212
Mar 10 10:12:55 mgchdxuxi sshd[8323]: Failed password for invalid user db2admin from 14.103.113.212 port 44082 ssh2
Mar 10 10:12:55 mgchdxuxi sshd[8323]: Received disconnect from 14.103.113.212 port 44082:11: Bye Bye [preauth]
Mar 10 10:12:55 mgchdxuxi sshd[8323]: Disconnected from 14.103.113.212 port 44082 [preauth]
Mar 10 10:14:35 mgchdxuxi sshd[8367]: Did not receive identification string from 87.236.176.152 port 34707
Mar 10 10:14:36 mgchdxuxi sshd[8368]: Connection closed by 87.236.176.152 port 41239 [preauth]
日志显示出有很多登录失败的信息,AI给出的结论是:
是的,你的服务器正在遭受自动化的暴力破解攻击(Brute Force Attack)。
黑客利用脚本不断尝试常见的用户名(如 root, admin, yann, silvia 等)和弱密码,试图撞库成功。
行为模式:脚本尝试一次密码,失败后立即断开,然后换下一个IP或下一个用户名继续试。速度非常快(几秒钟内多次尝试)。
解决步骤
- 安装 Fail2Ban
# 1. 安装 EPEL 源(如果没装过)
sudo yum install epel-release -y
# 2. 安装 fail2ban
sudo yum install fail2ban -y
# 3. 配置 SSH 防护
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo vi /etc/fail2ban/jail.local
- 配置策略
在 jail.local 中找到 [sshd] 部分,修改如下:
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/secure
maxretry = 2 # 允许失败2次
bantime = -1 # 封禁永久
findtime = 180m # 在180分钟内统计失败次数
- 启动服务
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
封禁效果
启动服务后,过几分钟就显示出了Ban了几个IP,十几个小时过去已经封禁了二百多个IP。
[root@mhwbc /]# sudo fail2ban-client status sshd
Status for the jail: sshd
|- Filter
| |- Currently failed: 7
| |- Total failed: 468
| `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd
`- Actions
|- Currently banned: 219
|- Total banned: 219
`- Banned IP list: 106.13.142.171 14.37.160.15 188.166.155.101 14.63.166.251 31.59.102.138 179.33.186.150 101.47.163.94 137.184.88.247 103.213.238.91 105.247.69.196 110.166.87.119 80.94.92.168 125.124.174.87 121.227.152.171 45.148.10.118 14.103.113.212 118.193.33.3 14.103.45.20 34.93.128.179 64.225.76.252 118.196.16.104 197.5.145.8 5.39.112.209 199.231.163.19 103.76.120.118 14.18.103.65 101.47.142.76 14.103.73.80 117.72.13.23 14.103.67.131 14.29.181.34 101.47.142.220 212.11.64.154 113.219.245.57 193.32.162.224 117.176.177.54 80.253.31.232 45.148.10.121 2.81.52.147 64.23.180.137 118.145.235.54 162.243.6.178 139.59.36.12 211.219.22.213 115.231.236.150 188.166.170.56 101.126.68.11 64.227.174.249 140.246.70.45 66.253.43.127 143.110.240.20 116.147.40.93 157.10.161.105 34.81.42.153 101.89.133.142 92.118.39.72 157.230.159.51 92.118.39.76 14.103.112.110 78.100.64.148 180.76.105.165 144.126.229.202 113.133.166.150 182.61.46.57 106.13.135.26 162.241.87.197 222.222.168.9 2.57.121.112 101.126.54.66 31.6.212.12 183.232.249.26 165.22.120.251 115.191.5.147 159.89.233.2 101.36.112.235 183.220.227.73 14.103.114.22 180.110.202.35 210.79.191.76 118.194.230.231 101.36.124.80 14.63.196.175 185.133.42.191 58.56.23.210 43.160.246.110 104.248.149.91 191.6.25.239 139.59.189.45 23.94.76.54 14.103.41.98 115.190.188.197 49.64.242.249 209.38.27.175 115.231.161.253 156.227.237.176 141.94.237.134 154.125.147.88 159.203.138.173 104.248.204.99 187.16.96.250 64.225.55.168 14.103.164.204 103.1.179.224 80.94.92.182 43.252.228.18 14.103.123.19 210.14.142.89 113.62.131.158 120.92.72.28 14.103.112.42 43.134.48.239 45.148.10.49 45.148.10.48 201.249.205.94 168.167.228.74 167.71.228.54 128.199.82.37 120.48.76.190 199.195.248.191 36.66.66.195 101.47.141.119 183.134.91.28 58.48.132.106 119.203.251.187 149.56.109.3 218.17.21.99 159.65.152.10 77.90.2.223 187.212.42.32 180.184.183.66 14.103.55.226 116.1.149.196 80.94.92.171 150.109.54.148 130.250.191.204 120.241.79.66 43.159.177.40 135.125.200.99 120.48.1.74 64.227.177.217 118.35.127.66 89.218.69.66 180.169.100.182 195.178.191.5 14.103.202.69 140.246.137.102 101.47.161.212 61.240.213.113 119.3.155.22 14.103.112.105 45.148.10.63 14.103.107.50 115.191.5.136 36.150.51.3 178.128.121.29 23.227.147.163 2.57.121.25 60.188.58.108 142.93.158.198 154.83.12.14 45.148.10.87 117.156.112.96 101.126.95.172 106.13.228.40 120.48.106.205 37.252.184.213 14.103.114.227 117.62.22.127 34.124.218.154 13.81.183.29 8.222.183.7 219.145.1.75 82.153.157.220 213.209.159.158 209.97.169.242 115.151.72.155 187.251.123.104 120.48.20.170 218.4.179.173 196.188.120.232 164.90.151.83 117.91.186.212 60.190.239.92 143.110.190.221 36.111.171.172 35.237.94.18 194.156.248.188 49.235.167.86 41.33.91.226 36.134.69.15 64.227.169.117 157.230.42.150 134.209.186.235 111.207.112.5 14.103.120.130 114.207.246.197 115.190.51.71 188.166.37.151 45.153.34.15 176.236.129.149 140.249.21.1 101.126.54.36 103.43.191.43 14.103.122.187 103.176.20.115 121.229.191.90 223.247.153.211 27.111.32.174 14.103.219.169 103.23.135.183 218.207.25.249 103.200.25.198 211.200.98.61 60.199.224.2 49.72.212.38 72.144.12.31 134.209.204.78 42.51.41.137 218.78.104.226
目前只是第一阶段的防护,至少不会因为网络阻塞而造成服务不可用了。
其他防护建议
- 启用CDN服务,以防IP地址暴露;
- 采用大厂服务器,天*yun就别用了,不稳定,问题多;
- 预警机制要做好,能够及时收到预警通知。
黑名单IP
- 2026-03-10更新,共计220个;
- 2026-03-11 10:18:12更新,共计476个;
- 2026-03-12 15:56:27更新,共计761个;
196.189.124.195
61.240.213.113
89.218.69.66
103.250.11.96
36.189.207.209
60.167.166.161
110.166.87.119
134.209.195.227
121.227.152.171
45.148.10.118
104.248.164.196
115.85.80.12
14.103.105.40
106.13.138.2
197.5.145.8
5.39.112.209
120.48.151.153
188.166.19.241
180.184.38.93
14.18.103.65
101.47.142.76
203.57.71.7
45.120.216.232
180.110.202.35
14.29.181.34
101.47.142.220
58.48.132.106
101.126.24.74
188.166.155.101
118.145.235.54
35.233.89.65
125.88.209.172
114.220.238.30
157.230.251.115
51.254.103.32
14.103.112.104
157.10.161.105
101.89.133.142
92.118.39.72
92.118.39.76
177.0.167.126
14.103.123.75
138.68.148.208
45.153.34.117
178.62.238.56
107.174.196.106
222.222.168.9
117.156.112.96
101.126.54.66
83.171.89.209
199.195.253.95
120.48.80.70
14.103.37.34
81.170.248.221
14.103.114.22
95.240.192.149
161.49.89.39
128.1.47.28
221.228.10.226
14.103.116.0
139.59.189.45
20.164.21.26
14.103.41.98
115.190.188.197
156.245.248.226
143.110.208.141
161.35.81.20
209.38.27.175
27.190.15.128
58.209.234.84
139.59.6.125
159.65.200.138
187.16.96.250
64.225.55.168
103.1.179.224
222.219.131.47
180.76.227.2
103.59.95.124
180.100.217.164
120.92.72.28
172.211.56.214
168.167.228.74
142.93.158.198
106.13.121.235
35.222.117.243
123.157.223.90
163.7.1.133
162.243.108.50
188.166.232.135
171.25.158.68
119.203.251.187
124.193.81.23
74.88.7.20
165.227.232.110
77.90.2.223
165.22.80.64
187.212.42.32
221.163.5.228
51.183.250.100
92.31.0.191
206.189.12.236
130.250.191.204
168.144.44.202
158.69.194.34
165.232.101.23
34.92.81.41
43.159.177.40
46.101.81.10
115.190.85.81
170.80.65.140
61.76.112.4
83.235.16.111
14.103.112.14
150.139.201.247
180.76.192.131
202.125.94.71
195.178.191.5
150.5.169.176
119.3.155.22
103.153.254.168
14.103.112.105
61.182.2.26
64.23.151.46
31.6.212.12
115.191.5.136
183.237.78.117
115.190.87.35
61.185.96.156
80.94.92.182
154.83.12.14
45.148.10.87
80.94.92.186
101.126.95.172
115.190.149.148
37.252.184.213
14.103.114.227
34.124.218.154
13.81.183.29
125.125.59.73
165.22.127.78
92.118.39.95
154.221.19.37
165.22.201.168
117.57.205.36
120.48.35.140
170.64.218.166
180.76.170.111
49.64.86.110
113.161.39.122
117.91.186.212
108.173.137.12
180.184.178.165
118.26.39.178
80.94.95.115
117.176.177.54
194.156.248.188
138.68.190.62
14.103.118.198
121.31.210.233
14.103.118.194
157.230.42.150
14.103.108.102
188.166.72.44
164.92.219.229
168.144.20.45
177.157.206.13
101.126.54.36
36.139.223.11
138.68.130.95
39.115.183.206
164.92.66.152
167.71.68.9
14.103.219.169
103.76.120.206
152.250.243.47
218.207.25.249
103.200.25.198
45.148.10.49
49.72.212.38
134.209.204.78
45.64.112.117
14.103.191.198
118.193.61.170
164.90.151.83
14.29.200.107
124.70.107.30
58.49.26.202
180.168.24.186
101.47.163.94
137.184.88.247
43.164.135.89
37.120.213.13
125.39.179.192
152.32.203.205
34.93.128.179
180.76.202.69
159.223.197.33
103.226.251.214
14.103.18.123
107.170.40.121
199.231.163.19
103.76.120.118
45.10.175.246
14.29.198.63
152.32.185.93
106.12.138.190
117.72.13.23
113.133.166.150
103.187.165.26
113.219.245.57
115.190.34.136
14.103.123.166
103.67.78.132
45.148.10.121
103.188.177.46
64.23.180.137
103.250.11.118
203.2.164.205
115.231.236.150
36.138.134.121
101.126.68.11
152.32.215.134
180.106.80.16
101.36.125.241
14.103.105.36
140.246.70.45
115.190.230.253
66.253.43.127
143.110.240.20
36.50.55.106
103.49.238.104
180.184.141.117
117.50.204.99
152.32.135.217
110.14.190.217
180.76.105.165
147.182.157.66
209.38.165.191
120.48.52.58
182.61.46.57
106.13.135.26
118.194.230.231
2.57.121.112
213.222.166.208
165.22.120.251
115.79.36.23
211.37.174.62
69.5.189.31
159.89.233.2
129.28.12.206
190.147.181.172
185.133.42.191
58.56.23.210
114.216.2.84
51.75.141.245
162.240.39.179
80.94.95.116
49.64.242.249
115.231.161.253
219.152.202.199
187.210.77.100
152.42.241.14
176.53.96.208
125.94.106.195
154.125.147.88
118.186.208.20
182.150.115.56
182.61.148.217
220.247.223.56
116.71.136.125
125.124.22.150
14.103.152.56
210.14.142.89
113.62.131.158
14.103.122.187
34.78.29.97
101.36.111.119
64.227.139.157
101.126.71.100
14.103.45.20
45.148.10.48
14.103.115.124
174.138.4.4
128.199.82.37
180.167.207.234
165.22.123.203
60.164.241.234
121.224.115.232
36.66.66.195
163.5.79.129
183.134.91.28
43.130.90.166
218.17.21.99
118.194.250.47
159.65.152.10
157.97.107.143
164.92.153.87
14.103.50.32
167.71.140.211
116.1.149.196
222.128.55.82
14.103.118.248
14.103.115.233
192.109.200.220
135.125.200.99
14.103.107.221
14.103.74.80
103.210.21.178
1.214.117.218
14.103.127.97
118.35.127.66
151.80.20.36
64.227.177.217
27.111.32.174
152.53.141.129
14.18.236.71
103.171.85.115
111.61.229.78
209.38.97.68
5.181.124.156
159.65.143.121
1.92.111.43
115.190.109.103
60.188.58.108
114.220.176.69
125.122.29.189
14.116.156.100
80.93.52.32
106.13.139.165
178.128.205.5
167.99.179.178
8.222.183.7
219.145.1.75
213.209.159.158
115.151.72.155
120.48.122.158
179.124.39.90
14.103.112.110
14.103.105.62
2.57.122.238
101.36.122.113
68.183.8.90
152.53.184.147
122.176.115.34
212.11.64.154
43.228.157.30
185.217.109.109
41.33.91.226
60.204.241.188
103.52.114.131
103.172.28.62
59.36.72.234
117.50.199.249
34.92.146.210
111.207.112.5
101.36.117.234
103.59.95.55
146.190.23.157
58.209.82.167
180.76.245.60
195.158.4.216
103.43.191.43
167.99.88.159
123.58.210.86
103.13.207.182
152.32.175.58
165.232.39.217
139.59.39.177
170.64.184.157
165.22.125.112
155.248.164.42
36.134.69.15
81.211.88.66
121.237.177.143
181.188.176.244
116.193.191.169
124.228.34.69
154.217.235.45
14.103.118.73
118.196.18.28
180.76.98.88
31.59.102.138
164.90.139.219
39.77.133.185
49.235.64.239
103.187.147.128
103.150.65.61
124.109.2.211
14.103.203.191
125.124.174.87
103.174.114.164
113.31.107.103
64.225.76.252
118.196.16.104
103.174.115.91
220.154.136.8
102.88.137.213
161.35.47.95
221.237.80.101
14.103.107.50
120.48.154.88
103.67.78.70
14.103.67.131
14.103.105.254
187.251.123.104
103.189.234.179
140.249.21.1
2.81.52.147
163.7.2.231
14.103.117.97
157.230.34.93
183.239.54.162
14.103.75.9
206.189.130.100
162.243.6.178
139.59.36.12
170.238.160.191
134.199.221.130
134.209.194.83
193.32.162.224
117.128.86.100
64.227.174.249
36.104.145.245
34.81.42.153
51.178.84.57
50.6.251.68
43.252.231.122
45.153.34.213
157.230.159.51
78.100.64.148
64.225.75.83
104.208.108.166
116.135.67.93
171.25.158.47
162.241.87.197
171.104.143.176
14.103.107.214
58.20.201.4
185.233.3.95
115.191.5.147
101.36.112.235
183.220.227.73
218.56.160.82
46.101.95.141
210.79.191.76
171.244.40.3
36.152.234.110
101.36.124.80
14.63.196.175
43.165.3.187
58.247.139.54
43.160.246.110
104.248.149.91
185.156.73.233
14.103.112.35
101.126.64.76
165.227.29.31
115.190.89.75
134.209.179.95
157.245.248.224
14.103.142.184
14.103.133.223
159.203.138.173
104.248.204.99
14.103.164.204
220.249.186.9
92.118.39.56
203.57.238.41
43.252.228.18
36.64.68.99
14.103.112.42
43.134.48.239
14.103.122.180
201.249.205.94
120.48.29.51
119.45.40.108
180.76.192.80
118.196.116.139
14.103.131.92
167.71.228.54
164.92.202.181
14.103.117.88
207.180.229.239
14.22.82.116
14.103.117.84
14.103.55.226
180.184.183.66
80.94.92.171
152.200.205.179
121.36.0.230
103.30.41.231
110.238.119.167
203.192.232.180
167.71.6.128
46.101.95.191
137.184.85.224
46.225.6.113
103.191.92.72
120.48.1.74
144.126.227.93
63.116.23.24
209.97.191.140
51.178.43.161
101.126.55.179
203.83.231.93
120.48.43.176
180.153.91.15
64.227.33.6
178.128.121.29
193.32.162.151
41.216.178.119
162.241.127.152
2.57.121.25
103.181.143.216
106.13.228.40
120.48.106.205
120.48.11.36
117.62.22.127
208.69.84.112
14.103.127.242
158.220.104.210
113.125.165.132
14.103.115.181
42.193.59.73
80.94.92.184
120.48.20.170
110.41.52.81
218.4.179.173
82.153.157.220
14.103.110.123
103.49.238.178
159.89.163.191
189.203.163.10
122.244.212.168
36.111.171.172
35.237.94.18
188.32.148.19
202.103.55.158
14.103.120.138
138.197.206.65
14.103.120.130
141.94.237.134
115.190.51.71
221.159.150.85
45.153.34.15
176.236.129.149
187.85.155.182
115.191.3.249
165.154.231.129
3.133.145.42
103.176.20.115
60.219.113.54
121.229.191.90
5.39.112.215
101.47.161.212
111.47.243.219
101.36.65.131
185.16.214.226
152.32.226.88
211.200.98.61
123.166.96.217
60.199.224.2
120.1.61.81
203.0.104.170
196.188.120.232
190.129.122.185
101.47.156.17
14.37.160.15
14.63.166.251
218.78.132.164
143.110.160.25
179.33.186.150
194.107.115.65
64.227.155.191
103.213.238.91
162.240.148.15
81.193.216.17
180.169.100.182
14.103.113.212
23.249.28.115
46.37.66.191
118.193.33.3
37.143.61.84
52.172.177.191
217.216.83.19
149.56.109.3
14.18.77.99
123.139.118.178
209.141.62.124
14.103.73.80
157.245.59.217
118.193.36.205
36.141.79.94
98.70.48.241
165.227.229.191
80.253.31.232
211.219.22.213
5.182.83.231
154.117.199.56
188.166.71.230
151.80.141.196
101.36.104.242
188.166.170.56
117.72.41.32
180.76.141.1
190.124.153.17
201.124.54.233
101.91.118.18
116.147.40.93
101.47.141.119
120.48.26.185
139.59.44.184
14.103.123.19
49.235.167.86
103.13.206.214
178.62.15.168
14.103.115.5
144.126.229.202
111.42.183.124
110.41.66.30
43.133.148.170
176.191.43.176
105.247.69.196
209.38.22.228
157.245.125.199
183.232.249.26
120.48.44.93
139.59.25.182
203.195.94.193
144.126.207.148
183.134.77.142
196.188.93.169
102.88.137.80
134.209.108.115
115.191.62.17
14.103.115.253
165.154.254.11
178.62.241.79
220.118.173.234
61.171.95.18
139.59.175.189
156.227.237.176
114.207.246.197
209.97.168.111
45.15.225.137
115.191.61.170
40.82.214.8
68.183.15.131
61.156.218.5
61.185.190.42
142.93.131.44
180.76.105.16
101.47.156.170
134.209.186.235
49.64.169.153
36.111.171.187
101.126.4.215
203.15.2.16
180.100.198.252
186.31.95.163
209.141.47.217
203.106.164.74
143.244.186.29
118.193.33.228
36.137.25.28
1.55.33.86
140.249.21.157
14.103.9.211
180.184.86.82
103.164.81.65
119.96.131.8
183.236.60.51
59.37.58.205
203.6.235.51
120.48.76.190
138.255.157.62
150.109.54.148
93.93.202.165
101.126.81.18
120.241.79.66
176.65.132.210
45.55.82.3
162.240.109.153
186.30.115.187
14.103.114.231
120.230.180.198
109.91.4.177
13.81.183.30
222.208.64.40
36.111.82.21
103.174.188.142
118.145.235.11
216.45.50.28
14.103.202.69
140.246.137.102
80.94.92.168
45.153.34.158
103.40.14.215
115.190.223.61
45.148.10.63
57.128.182.5
139.59.15.219
36.150.51.3
120.48.147.81
23.227.147.163
14.103.115.210
101.100.194.181
14.103.153.174
14.103.113.235
159.223.91.127
191.6.25.239
39.100.183.18
27.112.78.223
134.209.196.12
213.209.159.246
1.214.197.163
58.82.169.249
45.195.221.26
188.166.14.145
209.97.169.242
223.247.153.211
167.99.91.145
117.85.172.202
35.240.124.249
106.13.142.171
195.54.178.243
14.103.206.214
101.47.135.95
60.190.239.92
150.223.20.12
143.110.190.221
144.126.206.228
40.160.34.88
117.216.211.19
180.184.82.249
115.190.121.167
64.227.169.117
23.94.76.54
188.166.37.151
101.36.122.186
116.233.39.165
222.110.147.58
199.195.248.191
64.23.252.110
130.12.180.103
51.77.145.89
172.174.72.225
103.191.92.14
122.9.187.31
146.190.20.112
42.51.41.137
76.79.213.70
60.244.155.109
179.48.54.162
159.65.84.106
146.190.95.148
117.2.49.125
72.144.12.31
117.50.226.213
103.23.135.183
218.78.104.226
评论