fail2ban 升级版本

编程教程 > Linux > Linux Security (0) 2025-04-24 20:46:42

备份

备份现有配置和数据库以便回滚

备份配置

sudo mkdir -p /opt/fail2ban-bak
sudo cp -R /etc/fail2ban  /opt/fail2ban-bak

备份数据库

sudo cp /var/lib/fail2ban/fail2ban.sqlite3 /opt/fail2ban-bak

 

使用报管理器自动更新

该方案使用系统自带包管理器更新,会自动更新相关依赖。

查看最新版:

sudo apt update
sudo apt-cache madison fail2ban
 fail2ban |   0.11.2-6 | http://mirrors.tencentyun.com/ubuntu jammy/universe amd64 Packages

更新命令:

sudo apt upgrade fail2ban -y

等待完成安装即可

使用包管理器手动更新(官方方案)

切换到临时目录

cd /tmp/

下载安装文件和文件的验签信息

wget -O fail2ban.deb https://github.com/fail2ban/fail2ban/releases/download/1.1.0/fail2ban_1.1.0-1.upstream1_all.deb
wget -O fail2ban.deb.asc https://github.com/fail2ban/fail2ban/releases/download/1.1.0/fail2ban_1.1.0-1.upstream1_all.deb.asc

提示:你也可以手动下载好了上传上去

 

检查文件是否完好(胆大可以忽略)

检查文件是否原样,是否被修改,验证签名信息:

gpg --verify fail2ban.deb.asc fail2ban.deb

可能会报错:

gpg: Signature made Fri 26 Apr 2024 08:34:59 AM CST
gpg:                using RSA key 8738559E26F671DF9E2C6D9E683BF1BEBD0A882C
gpg: Can't check signature: No public key

报key没找到,国内好像访问不了公钥库,直接去备份库下载一个

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8738559E26F671DF9E2C6D9E683BF1BEBD0A882C

注意最后面的 8738559E26F671DF9E2C6D9E683BF1BEBD0A882C 就是上面的key

下载完成后再次校验

ubuntu@dev:/tmp$ gpg --verify fail2ban.deb.asc fail2ban.deb
gpg: Signature made Fri 26 Apr 2024 08:34:59 AM CST
gpg:                using RSA key 8738559E26F671DF9E2C6D9E683BF1BEBD0A882C
gpg: Good signature from "Serg G. Brester (sebres) <info@sebres.de>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 8738 559E 26F6 71DF 9E2C  6D9E 683B F1BE BD0A 882C

有个Good即可

查看软件包内容

dpkg -I fail2ban.deb
fail2ban 升级版本_图示-ae4978dc4da14510a252a31e5fffb403.png

停止现有版本服务

sudo service fail2ban stop

安装新版本

sudo dpkg -i fail2ban.deb

安装完成后查看版本:

ubuntu@dev:/tmp$ fail2ban-client --version
Fail2Ban v1.1.0.1

正常情况下,配置都还在,直接就用了。

如果安装被缺少依赖打断,请使用下面命令强行安装

sudo apt -f install fail2ban.deb

 

源码安装更新

Manual install/upgrade is very similar to aforementioned testing of standalone instance, just you have to do more steps to install it, like copy and enable service units, copy man-files etc pp.

Read more ...

Firstly download fail2ban from releases or from source (select branch master or 1.0, 0.11, 0.10 and click "clone or download" button) and unpack it (or clone it with git) into some temporary directory (e. g. )./tmp/f2b

In order to install it, you have to execute several of following commands as root (or sudoer), so you can start shell as root (e. g. ) or use before corresponding command that expecting administrator permissions.sudo -ssudo

- for fail2ban versions before or equal 1.0

  • install prerequirements you need (see README.md); for example:
    • for :python2
      apt install python-pyinotify python-systemd
    • for :python3
      apt install python3-pyinotify python3-systemd 2to3
  • if you want to use , enter and execute (and then use in command below)python3cd /tmp/f2b./fail2ban-2to3python3

- for fail2ban versions 1.1 or higher

  •  
  • enter your (cloned) interim fail2ban directory:
    cd /tmp/f2b
  • now install it:
    sudo python setup.py install --without-tests
  • note that the system init/service script is not automatically installed, so you have to copy it and enable the service manually; for example with init.d-script see readme, to install systemd-unit file use:
sudo cp ./build/fail2ban.service /etc/systemd/system/fail2ban.service
sudo systemctl enable fail2ban
 

Now we have to configure fail2ban (also see Proper fail2ban configuration):

  • copy your files from backup to (or create new and set-up jails you need to enable)..local/etc/fail2banjail.local
  • take a look in your backup copy of for includes made for your distribution:/etc/fail2ban/jail.conf
[INCLUDES]
before = paths-debian.conf
 
  • copy this file and set the same line in new or in .jail.confjail.local/etc/fail2ban
  • test it
    sudo fail2ban-client --test

Now you can start fail2ban via service:

sudo service fail2ban start
 
 

评论
User Image
提示:请评论与当前内容相关的回复,广告、推广或无关内容将被删除。

相关文章
备份备份现有配置和数据库以便回滚备份配置sudo mkdir -p /opt/fail2ban-baksudo cp -R /etc/fail2ban /opt
If not configured manually, Fail2ban will load configuration files from the dire
前言通过上一篇Fail2Ban安装和使用保护SSH免受暴力攻击-XQLEE'Blog安装和基本使用已经能满足Linux服务器对于ssh服务的防护工作了。这里接着
环境说明ubuntu系统Fail2ban 是一种多功能的安全工具。虽然它主要用于防止针对 SSH 的暴力攻击,但它也可用于保护其他服务。安装Fail2Ban软件
错误描述pve8或ubuntu fail2ban 无法启动 Have not found any log file for sshd jail导致原因没有找到s
Ubuntu系统或者Linux系统都应该保证软件更新到最新,以减少软件漏洞导致服务器风险。Ubuntu系统更新软件主要分两步。第一步:更新软件源信息该操作只会更新软件最新的信息到本地,不会下载和安装。
ddos攻击属于网络攻击的常见模式之一。这里写一个能简单防御的脚本ddos-deflate脚本的安装和卸载
Linux(centos)系统远程(SSH)登录输入错误密码多次锁定账号时间PAM实现方式
1.安装ufw防火墙sudo apt-get install ufw提示:除开精简版一般云提供商LTS版本(18/22LTS)都是默认安装的。 2.查看防火墙启
一、规则分类1.进入本机,即访问本机规则2.出本机,即本机访问外面规则3.转发,即本地转发规则,如端口7001转发到80 二、使用1.允许来自IP 10.1.1