Fail2ban

# 更新源并安装
sudo apt update && sudo apt install fail2ban -y

# 启动并设置开机自启
sudo systemctl start fail2ban
sudo systemctl enable fail2ban


cd /etc/fail2ban/

sudo vim jail.local

# Modify the following
#[SSHD]
enabled = true

port = 56789 # your own ssh port

mode = aggressive

logpath = /var/log/auth.log

backend = %(sshd_backend)s

#保存退出并重启fail2ban

sudo systemctl restart fail2ban

sudo fail2ban-client status sshd

#查看56789是否在输出的内容当中,类似 --dports = 56789

sudo fail2ban-client -d | grep -iE "sshd|port" | grep -v "filter"

 

Scroll to Top