16
My server is getting too many failed SSH login attempts. How can I block them?
Loading...
Q&A · Answered
My server is getting too many failed SSH login attempts. How can I block them?
Accepted answer
# Install fail2ban
sudo apt install fail2ban
# Create local config
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# Edit /etc/fail2ban/jail.local
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 3
bantime = 3600
# Start fail2ban
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
# Check status
sudo fail2ban-client status sshdSay what you tried, not only what worked — the next person needs the reasoning. Code goes in a fenced block.