EGR002 - Agent Cannot Run the Egress Firewall
Uploading.Agent error code #EGR002 indicates that the agent does not have the privilege it needs to change the egress firewall. On Linux and OpenBSD the command is installed but the agent is not allowed to run it as root. Changing the kernel's rules requires root, and the agent runs as its own unprivileged account, so it calls the command through sudo -n (or doas -n).. When neither is available, or the call is refused, every egress operation fails.
The agent cannot answer a password prompt, so a rule that asks for one counts as a refusal.
On Windows the agent changes Windows Firewall rules itself, which needs the agent service to run as LocalSystem. This code there means the service runs as some other account, or Windows Firewall could not be opened.
Common causes include:
knocknoc-agent account
The rule names a path that is not the command on this host
The rule requires a password
Neither sudo nor doas is installed
On Windows, the Knocknoc Agent service was changed to log on as another account
The commands the agent runs, by firewall:
nft
iptables
iptables, ip6tables, iptables-save, ip6tables-save, iptables-restore, ip6tables-restore
pf
pfctl
Steps to Resolve
Let knocker Write the Rule
knocker enable egress installs the rule the firewall needs and checks it with visudo before keeping it: /etc/sudoers.d/knocknoc-agent_nftables for nftables, /etc/sudoers.d/knocknoc-agent_iptables for iptables (the deb and rpm packages also install that one). On OpenBSD it adds a permit nopass line for pfctl to /etc/doas.conf. Re-running it is safe.
Check the Rule by Hand
sudo -l -U knocknoc-agent
Compare the paths in the rule with command -v for each command above. knocker's rules name both the /usr/sbin and /sbin paths.
Confirm the rule is NOPASSWD (or nopass for doas)
Try a read as the agent would, for example sudo -u knocknoc-agent sudo -n iptables-save -t filter
On Windows: Run the Agent as LocalSystem
services.msc) and find Knocknoc Agent
On the Log On tab, choose Local System account
Restart the service, or run sc stop KnocknocAgent then sc start KnocknocAgent from an elevated prompt