How to Secure Your Linux server with fail2ban and changing ssh port
How to Secure Your Linux server with fail2ban and changing ssh port
tested: Debian 10 x64 & CentOS 7 x64
software: OpenSSH server & fail2ban
1. update system
apt-get update && apt-get upgrade && apt-get dist-upgrade
yum update
2. change ssh port to 21348
nano /etc/ssh/sshd_config
change value:#Port 22
toPort 21348
3. install fail2ban
apt-get install fail2ban
4. copy jail.conf to jail.local
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
5. configuration:
nano /etc/fail2ban/jail.local
bantime = 60m
maxretry = 3
[sshd]
enabled = true
mode = aggressive
port = 21348
logpath = %(sshd_log)s
backend = %(sshd_backend)s
[dropbear]
enabled = true
port = 21348
logpath = %(dropbear_log)s
backend = %(dropbear_backend)s
6. save and restart
done
(saving with nano editor ctrl+x y enter)
show example: