Node Agent (Daemon)
monarch-daemon is the .NET 10 root agent running on every managed Linux host or Monarch server. It maintains a single outbound WebSocket connection to Monarch.panel and serves RPC calls and binary streams without opening any listening port or requiring SSH access.
Installation
Arch Linux (AUR)
yay -S monarch-daemon
Universal Linux installer (requires git and .NET 10 SDK)
curl -fsSL "https://code.weexnes.dev/monarch/daemon/~files/master/install.sh?raw=true" | sudo bash
You can also pass enrollment arguments directly after --:
curl -fsSL "https://code.weexnes.dev/monarch/daemon/~files/master/install.sh?raw=true" | sudo bash -s -- https://panel.example:4382 ccj_... --fingerprint 76BEA1...
Building from source
git clone https://code.weexnes.dev/monarch/daemon.git
cd daemon
dotnet publish -c Release -r linux-x64 --self-contained false -o ./publish
sudo cp -r ./publish /opt/monarch-daemon
sudo ln -sf /opt/monarch-daemon/Monarch.Daemon /usr/local/bin/monarch-daemon
Optional host tools detected automatically when installed: libvirt (virsh, virt-install, osinfo-db-tools), qemu-img, smartmontools, lvm2, docker/podman, firewalld/ufw, wireguard-tools, caddy, and acme.sh.
Enrolling a node
Remote enrollment
In Monarch.panel, go to Settings → Nodes → Add node to generate a single-use expiring join token (ccj_...) and view the panel's SHA-256 certificate fingerprint. Run the printed command as root on the target server:
sudo monarch-daemon join https://panel.example:4382 ccj_... --fingerprint 76BEA1...
This generates an ECDSA P-256 key pair, writes the public key during POST /api/enroll, stores the private key in /etc/monarch-daemon/daemon.key (0600), saves /etc/monarch-daemon/daemon.json, and installs monarch-daemon.service.
Same-host automatic enrollment (local-join.json)
When Monarch.panel runs on the same machine as monarch-daemon, the panel writes a 0600 local-join.json file in its data directory (~/.monarch-panel/local-join.json or /var/lib/monarch-panel/local-join.json) containing a loopback URL, token, and fingerprint. Only root and the panel user can read it; the local daemon picks it up automatically and deletes the file once enrolled.
CLI commands
| Command | Description |
|---|---|
join <url> <token> --fingerprint <sha256> [--no-service] [--force] |
Enroll with a one-time token and install systemd unit |
run |
Connect to panel and serve RPCs/streams (systemd ExecStart) |
status |
Show enrollment status, certificate pin, and SMBIOS UUID |
leave |
Remove enrollment config, key pair, and systemd unit |
install-service / uninstall-service |
Install or remove monarch-daemon.service |
version |
Print the daemon version |
Security & VM binding
- Challenge-response auth: On every WebSocket connect to
/ws/daemon, the panel sends a fresh random nonce. The daemon signscontrolcenter-daemon-auth:v2:<nonce>:<machineId>with its private ECDSA P-256 key. No shared secrets cross the wire. - TLS pinning: Plain
ws://is refused for everything except loopback. Remote connections require either--fingerprint <sha256>or a certificate trusted by the system CA store (no trust-on-first-use). - No shell execution: External programs are invoked directly as argv lists (
shell: false), argument names are validated (for example rejecting leading-), and sensitive values such as passwords forchpasswdare written to stdin. - SMBIOS UUID VM binding: The daemon reads
/sys/class/dmi/id/product_uuid. Because libvirt assigns each guest its domain UUID as the SMBIOS system UUID, a daemon running inside a VM is automatically matched to that VM in the panel rather than listed as an unrelated physical server (with MAC address fallback and manual override).