Linux安全设置:fail2ban防ssh爆破

实验环境CENTOS8

一、安装fail2ban

# dnf install epel-release -y

# dnf install fail2ban -y


二、修改fail2ban配置文件

# cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

# vim /etc/fail2ban/jail.local

修改sshd区块如下:

[sshd]

port = ssh

#logpath = %(sshd_log)s #centos8 需要屏蔽此区块

backend = %(sshd_backend)s

enabled = true #是否激活此项(true/false)

filter = sshd #过滤规则filter的名字,对应filter.d目录下得sshd.conf

action = iptables[name=SSH,port=22,protocol=tcp] #动作的相关参数,对应action.d/iptables.conf文件

logpath = /var/log/secure #检测系统的登陆日志文件

bantime = 300 #禁止用户IP访问5分钟

maxretry = 5 #5次密码验证失败

findtime = 300 #5分钟内出现规定次数就开始工作


三、开启fail2ban服务

# systemctl enable fail2ban.service --now

安全   Linux   ssh
发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章