Replace the hardcoded 40-char MeshID placeholder with a persisted per-group SHA-384 id so MeshAgent no longer fails with bad size on panel-downloaded .msh files.
4.8 KiB
MeshAgent onboarding on BetterDesk
BetterDesk ships a native MeshCentral compatibility layer in betterdesk-server (optional module).
BetterCore / BetterViewer
MeshAgent receives BetterCore (agent-side JS) after the binary handshake. The panel remote viewer uses BetterViewer for MNG_KVM desktop sessions (transport=mesh).
BetterCore includes: user consent prompts (desktop/terminal/files), WebRTC relay handoff (webrtc0–webrtc2, SDP offer/answer), PowerShell terminals (p=6 admin, p=9 user on Windows), and TCP/UDP port relay (POST /api/mesh/devices/{id}/tcp / udp).
Operator actions (panel)
For online mesh_agent devices, the device menu includes:
- Web Remote — KVM desktop (
transport=mesh) - Terminal — interactive shell (
p=1) - File browser — remote files (
p=5) or?panel=fileson web remote - Run command — one-shot
runcommandson the agent channel - Guest desktop link — time-limited view-only URL (
mesh_sharetoken) - TCP port relay — browser tunnel to a host/port on the agent LAN
- Sleep / Reset —
devicepowervia MeshAgent (POST /api/mesh/devices/{id}/power)
Power wake on sleeping agents follows MeshCentral rules (other agents on the mesh send WoL); use RustDesk WoL on linked peers when a MAC is known.
Session recording (server-side .mcrec capture): open web remote with ?record=1 on the desktop tunnel request (operator session).
Interop CI
betterdesk-server/meshcentral/interop/run-interop.sh runs:
- Simulated MeshAgent handshake (
TestAgentHandshakeInterop) — full binary auth + BetterCore push. - Live MeshAgent binary (
TestMeshAgentLiveConnect,-tags=meshagent_live) — downloadsmeshagent_x86-64from MeshCentral agents bundle.
GitHub Actions job mesh-interop in .github/workflows/go-server-ci.yml runs both steps on every betterdesk-server change.
Enable
The MeshCentral compatibility layer is enabled by default on full and minimal installs (MESH_ENABLED=Y). To disable, set MESH_ENABLED=N in the betterdesk-server service environment and restart the service.
- Ensure panel HTTPS (
:5443) proxies.ashxpaths to the Go API port (default21114) — enabled automatically when using the Node.js console.
Install endpoints
- In the panel (or via API
GET /api/mesh/download.msh), download the generated.mshfile. - Confirm
MeshID=is0x+ 96 hex characters (or 64). Shorter values cause MeshAgentbad sizeand will not connect. - Install unmodified MeshAgent on Windows/Linux/macOS using that file.
MeshServerin the file points towss://your-host/agent.ashx;ServerIDpins the agent-server RSA certificate (MESH_AGENT_CERT_FILE) — not the public HTTPS/Let's Encrypt cert.
Behind an external reverse proxy (Nginx / NPM / Caddy)
TLS usually terminates at the proxy. MeshAgent hashes the public TLS cert it sees on MeshServer and BetterDesk compares that to a configured web cert hash.
| Variable | Role |
|---|---|
MESH_WEB_CERT_FILE |
Preferred: path to the public cert agents see (e.g. LE fullchain.pem). Used for mesh web-hash only. |
TLS_CERT |
Fallback source for web-hash when MESH_WEB_CERT_FILE is unset (also used for Go signal/relay TLS). |
| (neither set) | Web-hash validation is skipped (typical native “external reverse proxy” install). |
Do not put mesh_agent_server.pem in MESH_WEB_CERT_FILE — that is ServerID, not the web TLS pin.
Preferred proxy path: wss://host/agent.ashx → panel :5000 (.ashx WebSocket proxy to Go). Direct proxy to :21114 works if Upgrade headers are set, but still requires a matching web cert hash when validation is enabled.
If logs show bad web cert hash / agent web cert hash mismatch: mount the proxy’s leaf/fullchain into the Go container and set MESH_WEB_CERT_FILE, or unset both MESH_WEB_CERT_FILE and TLS_CERT to skip the check.
Verify
- Device appears in Devices with
device_type: mesh_agentand online status when connected. - Remote desktop: open
/remote/:deviceId— transport auto-selectsmesh. - API:
GET /api/peers/{id}includesmesh_connected: trueandmesh_node_id.
Hybrid hosts (RustDesk + MeshAgent)
When MeshAgent and RustDesk client run on the same machine, BetterDesk auto-links peers by hostname when possible. Operators can also set linked_peer_id manually via the CDAP link API or device edit.
Security
- Back up
MESH_AGENT_CERT_FILE(defaultmesh_agent_server.pem). Loss requires re-enrolling all MeshAgents with a new.msh. - Keep
MESH_ENABLED=Non relay-only nodes if you explicitly disable the module; default is on.
Update
Ships via Settings → Updates (panel updater) like other betterdesk-server and web-nodejs changes.