首先更新源

apt update

然后安装fail2ban

apt install fail2ban -y

启用fail2ban服务,并使其开机启动。

systemctl start fail2ban
systemctl enable fail2ban

配置22端口的防御

nano /etc/fail2ban/jail.local

输入

[sshd]
enabled = true
port = 22
filter = sshd
logpath = /var/log/auth.log
maxretry = 3

然后重启服务。

systemctl restart fail2ban

测试。

[email protected] ~ # fail2ban-client status sshd
Status for the jail: sshd
|- Filter
|  |- Currently failed:    0
|  |- Total failed:    15
|  `- File list:    /var/log/auth.log
`- Actions
   |- Currently banned:    1
   |- Total banned:    4
   `- Banned IP list:    218.92.0.169

标签: ubuntu, ssh, fail2ban

添加新评论