How to secure SSH with fail2ban

Answered
Jan 05, 2026 1186 views 1 answers
16

My server is getting too many failed SSH login attempts. How can I block them?

N
Asked by noor_code
Gold 255 rep

1 Answer

13
# 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 sshd
D
Answered by db_admin 1 week, 2 days ago
Silver 415 rep

Your Answer

You need to be logged in to answer questions.

Log In to Answer

Related Questions

Hot Questions

No hot questions available.