修改SSH端口
修改配置文件
sudo vi /etc/ssh/sshd_configsudo systemctl restart sshd配置防火墙
使用UFW只放行必要端口
sudo apt update && sudo apt install ufw -ysudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcpsudo ufw enable封禁异常登录ip
安装 Fail2ban 防止暴力破解
sudo apt install fail2ban -ysudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo vim /etc/fail2ban/jail.localenabled = true
port = 22
logpath = %(sshd_log)s
maxretry = 3
bantime = 3600sudo systemctl enable fail2ban && sudo systemctl start fail2bansudo fail2ban-client status sshd