![如何在自定义根位置从源安装 fail2ban?](https://linux22.com/image/744094/%E5%A6%82%E4%BD%95%E5%9C%A8%E8%87%AA%E5%AE%9A%E4%B9%89%E6%A0%B9%E4%BD%8D%E7%BD%AE%E4%BB%8E%E6%BA%90%E5%AE%89%E8%A3%85%20fail2ban%EF%BC%9F.png)
从源代码安装顺利:
sudo apt-get remove fail2ban
wget https://github.com/fail2ban/fail2ban/archive/0.10.3.tar.gz
mv 0.10.3.tar.gz fail2ban-0.10.3.tar.gz
gzip -d fail2ban-0.10.3.tar.gz
tar -xvf fail2ban-0.10.3.tar
cd ~/programs/fail2ban-0.10.3
mkdir ~/programs/install/fail2ban
sudo python setup.py install --root=~/programs/install/fail2ban
sudo cp files/debian-initd /etc/init.d/fail2ban
sudo update-rc.d fail2ban defaults
sudo systemctl unmask fail2ban.service
sudo service fail2ban start
但后来客户失踪了:
stephane@thalasoft:~/programs/fail2ban-0.10.3$ sudo fail2ban-client version
sudo: fail2ban-client: command not found
stephane@thalasoft:~/programs/fail2ban-0.10.3$ fail2ban-client version
Command 'fail2ban-client' not found, but can be installed with:
sudo apt install fail2ban
stephane@thalasoft:~/programs/fail2ban-0.10.3$ find ../install/fail2ban/ -name fail2ban-client
../install/fail2ban/usr/local/bin/fail2ban-client
stephane@thalasoft:~/programs/fail2ban-0.10.3$ ll ../install/fail2ban/usr/local/bin/
total 24
drwxr-xr-x 2 root root 4096 Oct 19 13:18 ./
drwxr-xr-x 4 root root 4096 Oct 19 13:18 ../
-rwxr-xr-x 1 root root 1418 Oct 19 13:18 fail2ban-client*
lrwxrwxrwx 1 root root 15 Oct 19 13:18 fail2ban-python -> /usr/bin/python*
-rwxr-xr-x 1 root root 1279 Oct 19 13:18 fail2ban-regex*
-rwxr-xr-x 1 root root 1416 Oct 19 13:18 fail2ban-server*
-rwxr-xr-x 1 root root 2284 Oct 19 13:18 fail2ban-testcases*
stephane@thalasoft:~/programs/fail2ban-0.10.3$ ../install/fail2ban/usr/local/bin/fail2ban-client
versionTraceback (most recent call last):
File "../install/fail2ban/usr/local/bin/fail2ban-client", line 34, in <module>
from fail2ban.client.fail2banclient import exec_command_line, sys
ImportError: No module named fail2ban.client.fail2banclient
stephane@thalasoft:~/programs/fail2ban-0.10.3$ ../install/fail2ban/usr/local/bin/fail2ban-client version
Traceback (most recent call last):
File "../install/fail2ban/usr/local/bin/fail2ban-client", line 34, in <module>
from fail2ban.client.fail2banclient import exec_command_line, sys
ImportError: No module named fail2ban.client.fail2banclient
答案1
您可以尝试该命令which fail2ban-client
,如果它没有返回任何内容,则再尝试find ~ -type f -name fail2ban-client
。
如果你还没有在家中安装它或者你更改了用户,这个命令(生成许多警告)肯定会找到它(如果你在那个盒子上有它)sudo find / -type f -name fail2ban-client
:。
一旦你得到了它,要么执行它/full/path/to/fail2ban-client
,要么关注此人使所有 fail2ban 二进制文件可用且不/full/path/to
带前缀。