Secure your SSH login against brute-force attacks using keys and monitoring tools.
- Edit config:
nano /etc/ssh/sshd_config, then setPermitRootLogin no,PasswordAuthentication no,PubkeyAuthentication yes. - Create non-root user:
adduser secureuserandusermod -aG sudo secureuser. - Copy SSH key: From local,
ssh-copy-id secureuser@your-server-ip. - Install Fail2Ban:
apt install fail2banand configure jail for SSH. - Restart:
systemctl restart ssh. - Test login with new user and key before closing your current session.