1. SSH 密钥登录

ssh-keygen -t ed25519 -C "your@email.com"
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server

编辑 /etc/ssh/sshd_config,设置 PasswordAuthentication no,重启 SSH。

2. Fail2ban

sudo apt install fail2ban -y
sudo systemctl enable fail2ban --now