Skip to content

Running with systemd

Running the agent as a systemd service ensures it starts automatically on boot and restarts if it crashes.

  • Linux system with systemd
  • EpochProxy agent installed to /usr/local/bin/epoch-agent
  • Agent already activated (has valid state file)
Terminal window
sudo nano /etc/systemd/system/epoch-agent.service

Paste the following:

[Unit]
Description=EpochProxy Agent
Documentation=https://docs.epochproxy.cloud
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/epoch-agent --state-file /var/lib/epoch-agent/state.json
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
# Security hardening (optional but recommended)
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=read-only
ReadWritePaths=/var/lib/epoch-agent
[Install]
WantedBy=multi-user.target
Terminal window
sudo mkdir -p /var/lib/epoch-agent

If you haven’t activated the agent yet, run it manually first:

Terminal window
sudo epoch-agent --activation-code YOUR_CODE --state-file /var/lib/epoch-agent/state.json

Press Ctrl+C after you see “Agent is ready”.

Terminal window
# Reload systemd to recognize the new service
sudo systemctl daemon-reload
# Enable the service to start on boot
sudo systemctl enable epoch-agent
# Start the service now
sudo systemctl start epoch-agent
Terminal window
sudo systemctl status epoch-agent

You should see “active (running)”.

Terminal window
sudo systemctl status epoch-agent
Terminal window
sudo systemctl start epoch-agent
sudo systemctl stop epoch-agent
sudo systemctl restart epoch-agent
Terminal window
# Recent logs
sudo journalctl -u epoch-agent -n 50
# Follow logs in real-time
sudo journalctl -u epoch-agent -f
# Logs since boot
sudo journalctl -u epoch-agent -b
Terminal window
sudo systemctl disable epoch-agent

For additional security, run the agent as a dedicated user:

Terminal window
sudo useradd --system --no-create-home --shell /usr/sbin/nologin epoch-agent
Terminal window
sudo mkdir -p /var/lib/epoch-agent
sudo chown epoch-agent:epoch-agent /var/lib/epoch-agent

Change the User line:

[Service]
User=epoch-agent
Group=epoch-agent
Terminal window
sudo systemctl daemon-reload
sudo systemctl restart epoch-agent

Instead of command-line arguments, use a config file:

Terminal window
sudo mkdir -p /etc/epoch-agent
Terminal window
sudo nano /etc/epoch-agent/config.toml
[api]
url = "https://api.epochproxy.cloud"
[shell]
path = "/bin/bash"
ExecStart=/usr/local/bin/epoch-agent --config /etc/epoch-agent/config.toml --state-file /var/lib/epoch-agent/state.json

Check the logs:

Terminal window
sudo journalctl -u epoch-agent -n 100 --no-pager

Ensure the state directory is writable:

Terminal window
sudo chown -R epoch-agent:epoch-agent /var/lib/epoch-agent

The agent may be failing to connect. Check:

  1. Network connectivity to api.epochproxy.cloud
  2. Valid activation code or state file
  3. Firewall rules allowing outbound connections