跳至主要內容

Fail2ban

wangdx小于 1 分钟

如何在 Ubuntu 22.04 上安装和配置 Fail2banopen in new window

linux 清除 last、lastb 和 history 记录open in new window

sudo apt install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
sudo systemctl status fail2ban
#配置 Fail2ban
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
vim /etc/fail2ban/jail.local

ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24 192.168.10.20

bantime  = 1d
findtime  = 10m
maxretry = 5

action = %(action_mw)s
destemail =

banaction = ufw

[sshd]
enabled   = true
maxretry  = 3
findtime  = 1d
bantime   = 1w

port    = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s


sudo systemctl restart fail2ban

sudo fail2ban-client status sshd

linux 清除 last、lastb 和 history 记录

#此时即看不到用户登录信息
echo ""> /var/log/wtmp
#清除登录系统失败的记录
echo  ""> /var/log/btmp
#清除历史执行命令  echo ""> ./.bash_history
history -c
上次编辑于: