# yum install fail2ban
설치가 완료되면 fail2ban이 SSH에 적용되도록 설정해준다.
# vi /etc/fail2ban/jail.conf
jail.conf를 열어서
# [sshd]
# enabled = true
위의 주석을 해제한다.
[sshd]
enabled = true
접속 시도 횟수와 차단 시간에 대한 설정은 아래와 같다.
bantime = 600
findtime = 600
maxretry = 5
findtime에 지정된 시간 이내에 maxretry만큼 접속을 실패할경우,
bantime에 지정된 시간만큼 접속을 차단한다(초 단위).
root@raspberrypi:~# iptables -nvL Chain INPUT (policy ACCEPT 12 packets, 900 bytes) pkts bytes target prot opt in out source destination 607 60607 fail2ban-ssh tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 7 packets, 896 bytes) pkts bytes target prot opt in out source destination Chain fail2ban-ssh (1 references) pkts bytes target prot opt in out source destination 16 1464 REJECT all -- * * 222.186.21.102 0.0.0.0/0 reject-with icmp-port-unreachable 17 1416 REJECT all -- * * 116.31.116.15 0.0.0.0/0 reject-with icmp-port-unreachable 574 57727 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 |