1

上周我问了这个关于安全溢出的问题,但是没有回复,所以我希望你能在这里提供帮助。问题如下:

因此,我正忙于在 VM 上设置一个 knockd 服务,以便在使用 knockd 和 ufw “敲入”正确的端口序列时启用 SSH 登录。

The issue that I am currently having is that when the correct sequence of ports are selected, the user.rules for ufw is not able to write the new rule to a file.

我尝试在 /etc/ufw 中的所有文件上使用 chmod 777 作为测试,但是该文件仍然不可写。

/etc/ufw/user.rules 的输出如下:

Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/after6.rules is world writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/after6.rules is group writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/user6.rules is world writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/user6.rules is group writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/applications.d is world writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/applications.d is group writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/user.rules is world writable!
Jun 14 13:13:31 Pop knockd[4780]: WARN: /etc/ufw/user.rules is group writable!
Jun 14 13:13:31 Pop knockd[4780]: ERROR: '/etc/ufw/user.rules' is not writable
Jun 14 13:13:31 Pop knockd[4780]: openSSH: command returned non-zero status code (1)

knockd 文件如下面的代码块所示:

[options]
        logfile = /var/log/knockd.log

[openSSH]
        sequence    = 7000,8000,9000
        seq_timeout = 5
        command     = ufw allow 22/tcp
        tcpflags    = syn

[closeSSH]
        sequence    = 9000,8000,7000
        seq_timeout = 5
        command     = ufw delete allow 22/tcp
        tcpflags    = syn

/etc/default/knockd 的输出如下所示:

# control if we start knockd at init or not
# 1 = start
# anything else = don't start
# PLEASE EDIT /etc/knockd.conf BEFORE ENABLING
START_KNOCKD=1

# command line options
KNOCKD_OPTS="-i enp0s3"

任何建议将不胜感激。

4

3 回答 3

4

首先注意警告并重置您更改的所有文件的权限。让所有用户都拥有防火墙规则的写入权限并不是一个好主意。那就是:

chmod -R ga-w /etc/ufw

然后在 knockd.service 文件(位于 /lib/systemd/system/ 文件夹中)禁用(注释掉或将显式设置为关闭)ProtectSystem 指令。

如果可行,请将其重置为完整并放在其下方

ReadWritePaths=-/etc/ufw/

ProtectSystem=full 为单元调用的进程(不包括在 ReadWritePaths 中指定的目录)安装 ro /usr、/boot 和 /etc。

如果正在运行,在重新启动服务之前执行

systemctl daemon-reload
于 2017-08-18T03:33:58.123 回答
0

我有同样的问题,但通过清理 ip4 和 ip6 表解决了它。在一条错误消息中,它说“xtable”被另一个进程锁定。

ufw disable
iptables -F
iptables -X
ip6tables -F
ip6tables -X
ufw enable

尝试敲门然后检查

service knockd status
于 2017-08-03T09:33:06.580 回答
0

我遇到了同样的问题,有一个 knockd /etc/ufw/user.rules not writeable 错误。敲击数据包出现在 syslog 中,并且尝试了 ufw insert 1 ... 命令。我目前对原因的最佳猜测是 cgroups 系统。

在 /etc/knockd.conf 中使用 iptables 命令而不是 ufw 命令对我有用。

于 2017-07-05T13:10:27.283 回答