11. Install agents on Linux (and macOS)
This guide describes Lawliet 1.6.3.b (the current release, a beta: earlier releases are beta. The first stable release will be 2.0.0). Screens, commands and procedures may change in later versions; the usage guide is updated with each release. Check the version your server runs under Settings > Platform or with ./lawliet version, and see the Releases page for what changed.
This chapter installs, upgrades and removes the agent on Linux hosts, and at the end on macOS. For what the agent does, read chapter 10 first. To install from the console without logging in to each host, see chapter 13.
11.1 Before you start#
| Requirement | Detail |
|---|---|
| Operating system | 64-bit Linux with systemd |
| CPU | amd64 (x86_64) or arm64 (aarch64). Another CPU falls back to the Python agent |
| Libraries | glibc 2.17 or later (the compiled agent's baseline) |
| Python | Not needed. Only the Python fallback needs python3, python3-venv and a package mirror |
| Disk | About 35 MB under /opt/lawliet-agent, plus room for its unpacked runtime |
| Account | root, or a user with sudo |
| Network | Outbound from the host to the server: 443/tcp (HTTPS mode) or 8000/tcp (lab mode) |
| Clock | Within 1 minute of the server. Use NTP |
You also need, from the server administrator:
- the server address the hosts reach (a name or an IP address, never
localhost); - for a self-signed server certificate, the certificate file
lawliet-server.pem.
Make the certificate file on the server:
sudo ./lawliet tls --export # writes ./lawliet-server.pemCopy it to each host, for example to /root/lawliet-server.pem.
11.2 Procedure: install with the copy-paste command#
Use this when the host can reach the server.
Required permission (console): Manage agents (to see the filled-in command). On the server, sudo ./lawliet token prints the same command. Four-eyes: no.
Risk: installs a root service on the host. Rollback: uninstall it (11.6).
- Get the command. Either:
- Console: Environment > Hosts > Install agent > Install command > Linux, then the copy button. If the server's certificate is self-signed, keep Self-signed certificate ticked.
- Server:
sudo ./lawliet token, section "Linux".
- If the server certificate is self-signed, copy
lawliet-server.pemto the host as/path/to/lawliet-server.pem, or edit that path in the command (it appears twice). - Open a terminal on the host and paste the command. It is one line. Its shape is:
d="$(mktemp -d)" && curl -fsSL --cacert /path/to/lawliet-server.pem -o "$d/install.sh" https://<server>/api/v1/agents/download/linux && head -c 2 "$d/install.sh" | grep -q '^#!' && sudo bash "$d/install.sh" --server https://<server> --token <enrolment-secret> --ca-cert /path/to/lawliet-server.pem; rc=$?; rm -rf "$d"; [ "$rc" -eq 0 ]Do not type it by hand: copy it, it carries the enrolment secret.
- Wait for the installer to finish (normally under a minute).
What you see on the host: the installer checks the server, downloads the compiled agent, checks its SHA-256, installs it as /opt/lawliet-agent/lawliet-agent, starts the lawliet-agent and lawliet-watchdog services and waits up to 60 seconds for enrolment.
What you see in the console: the host appears on Environment > Hosts within about a minute, status online.
If it fails: the installer prints one plain verdict and its fix (see chapter 10.9). A download that fails installs nothing. Exit status 3 means the server refused the enrolment; the message gives the reason (401: wrong secret; 409: an older record of this host exists - remove it in the console and the agent enrols by itself).
Note: the console's step text says the script "installs Python dependencies". The compiled agent needs none; Python is used only by the fallback.
11.3 Procedure: install from an offline package#
Use this when the host cannot download anything from the server.
Required permission: Deploy agents remotely (it also makes offline packages). Four-eyes: yes in the console (critical action "Deploy agents remotely"). The server CLI needs root and no second signature.
Risk: a package holds an enrolment code that lets hosts join until it expires. Treat it like a password. Rollback: revoke the code (11.3.3); uninstall the agents (11.6).
11.3.1 Make the package in the console#
Open Environment > Hosts > Install agent > Offline package.
Fill in the form:
Field What to enter Target Linux x86-64 or Linux ARM64. A target the server does not carry shows "(not on this server)" Label A name you will recognise, for example "Plant floor" Valid for (days, at most 30) Default 7 Hosts it may enrol (at most 1000) Default 50. Each host that enrols uses one Server address the hosts reach Filled in; change it if the hosts reach the server by another address Server certificate (PEM) Shown for a self-signed server. The certificate the server serves is packed automatically; paste one only to pack a different file Click Request package. What you see: "Sent for approval (request #N). Once a second person approves it, create the package here."
A second administrator approves it under Approvals > Waiting for me (the request shows the target, hosts, days, address and certificate).
Back in Install agent > Offline package, click Check again, then Create package. (You can also run it from Approvals > My requests > Execute now.)
What you see: "Package ready", the enrolment code (shown once), the Package SHA-256 - note it down, and a Download link. Download the file now: the link works once, for you, for 15 minutes. A package nobody downloads is deleted after an hour.
11.3.2 Or make the package on the server#
sudo ./lawliet agent-package --os linux --arch amd64 --hosts 50 --days 7 --label "Plant floor"| Option | Meaning |
|---|---|
--os linux | Linux package |
--arch amd64 or arm64 | CPU (default amd64) |
--hosts N | How many hosts may enrol, 1 to 1000 (default 50) |
--days N | Validity, 1 to 30 (default 7) |
--label TEXT | Name shown in the console |
--server URL | Address the hosts reach, if different from the server's own |
--out DIR | Where to write the file (default: the install directory) |
What you see: the file name, the enrolment code number, the expiry, the agent SHA-256 and the Package SHA-256. Note the package SHA-256 and copy the file to the host by your approved channel. The code is audited as made through the CLI, and is revoked like any other (16.6).
11.3.3 Install the package on the host#
- On a trusted machine, compare the package's SHA-256 with the value the console or the CLI showed:
sha256sum lawliet-agent-linux-amd64-offline-12.tar.gzDo not install it if they differ.
- Copy the archive to the host (USB stick, a share,
scp). - On the host, as root:
tar xzf lawliet-agent-linux-amd64-offline-12.tar.gz sudo bash lawliet-agent-linux-amd64/install_linux.sh --offline-package lawliet-agent-linux-amd64You can also give the archive itself:
--offline-package <file>.tar.gz.
What you see: "Package contents match its checksum list", then the install. Nothing is downloaded. If the host can reach the server, it enrols at once. If it cannot yet, the installer says "Installed; it will enrol automatically once this host can reach <server>" and exits 0; the agent keeps trying while the code is valid.
If it fails:
| Message | Fix |
|---|---|
A file does not match SHA256SUMS, or a file is missing | The copy is damaged or changed. Get a new copy and check step 1 again |
| Package for another CPU or OS | Make a package for the right target |
| "the enrolment code in this host's offline package is not valid" | The code expired or is used up. Make a new package and install it over the old one |
| 409 | An earlier record of this host is still in the console. Delete it (an enrolment code never takes over an existing agent) |
Afterwards, the code is removed from /opt/lawliet-agent/config.env once the agent has enrolled (from 1.5.14.s the same holds for an install with --token, the registration secret). To check (prints 0 when it is gone):
grep -c '^LAWLIET_REGISTRATION_SECRET=.' /opt/lawliet-agent/config.envRevoke the code when you are done: Install agent > Offline package > Enrolment codes > Revoke. Revoking needs only the permission (it takes risk away). Hosts already enrolled are not affected. The list shows each code's label, target, uses (for example 12/50), expiry, status (active, expired, exhausted, revoked) and the last host that used it.
11.4 Installer options#
To use an option:
- Start from the command in 11.2 (or 11.3.3) and add the options you need, for example
--name web-01or--sha256 <hash>. - Run it as root on the host.
- What you see: the installer prints each step and ends with the agent running; the options it was given are reflected in the result (for example the console name).
| Option | Purpose |
|---|---|
--server URL | Server address. HTTPS unless --insecure |
--token SECRET | Enrolment secret. Without it the server refuses the enrolment (401) |
--name NAME | Name shown in the console (default: the host name) |
--ca-cert PATH | Trust this server certificate. Required for a self-signed server |
--sha256 HASH | Check the downloaded agent against a hash you got separately |
--local-binary PATH | Install this compiled agent file instead of downloading it. Needs --sha256. The file and its folder must be owned by root and not writable by others |
--offline-package PATH | Install from an offline package (folder or archive). Cannot be combined with --server, --token or --ca-cert |
--python | Install the Python fallback agent |
--reset-token | Enrol again as a new agent, also with the same server (a server rebuilt at that address). The old enrolment is kept as agent.conf.repoint-<time> |
--refresh-ca | With --ca-cert: give the installed agent a new server certificate; nothing is re-enrolled |
--uninstall | Remove the agent (11.6) |
--code CODE | With --uninstall: an uninstall code for a protected agent |
--recovery-key KEY | With --uninstall: the installation's recovery key |
--insecure | Allow a plain-HTTP server. Lab only, never production |
--allow-custom-commands | Let this host run operator custom commands (36) when the server allows them too. Off unless given; kept in /etc/lawliet/local-policy.json, which no server setting can change |
--no-custom-commands | Turn custom commands off again on this host. With neither option a reinstall keeps the host's choice |
Moving a host to another Lawliet server: run the new server's command. When --server differs from the address in the installed config.env, the installer stops the agent, keeps the old enrolment as agent.conf.repoint-<time>, forgets the old server's trust key, and reports success only once the new server has enrolled the host; otherwise it exits 4 and keeps the enrolment secret so the agent keeps trying. A server that already has this host on record (409, usually the same server under another address) gets the previous enrolment back and exit 5. The newest 3 backups are kept. The same server again changes nothing; for a server rebuilt at the same address use --reset-token. macOS does the same.
Take a hash for --sha256 from a source that did not travel with the file (the release notes, or the server). Never from a .sha256 file next to the binary.
11.5 Managing the agent on the host#
Run these as root. What you see: active (running) from systemctl status, recent heartbeat and command lines in the log, and the host online in the console within a minute of a restart.
systemctl status lawliet-agent # is it running
journalctl -u lawliet-agent -n 50 --no-pager # recent log
journalctl -u lawliet-agent -f # live log
sudo systemctl restart lawliet-agent # restartWith self-protection on, the services restart themselves if stopped, and the watchdog restores the program file. Use the console to turn protection off first (chapter 16).
| Path | Content |
|---|---|
/opt/lawliet-agent/lawliet-agent | The compiled agent |
/opt/lawliet-agent/lawliet-agent.known | Known-good copy the watchdog restores from |
/opt/lawliet-agent/config.env | Settings (10.5) |
/etc/lawliet/agent.conf | Agent id and token (mode 600) |
/etc/lawliet/server-ca.pem | The trusted server certificate |
/etc/systemd/system/lawliet-agent.service, lawliet-watchdog.service | Services |
Re-running the installer upgrades the agent in place and keeps the host's identity. The new program is checked and started once before the old one stops. If anything fails, the previous program, services and settings are put back.
11.5.1 Endpoint telemetry: what the agent adds to auditd#
While endpoint telemetry (EDR) is on for the host's group, the agent collects process starts and ends, outbound and inbound connections and writes to sensitive paths. There is nothing to run on the host; the profile (light, standard, full) is chosen in the console. What the agent does to the host's audit setup, so you can answer the host owner or their auditor:
| Rules | Lawliet's own syscall rules (process execution, connects, accepts; key lawliet-edr-*), loaded when the agent starts and taken out when it stops, crashes or is disabled (the unit's ExecStopPost runs /var/lib/lawliet/edr-unload.sh), when telemetry is turned off, and on uninstall. There is no boot-time rules file, so nothing reloads them without the agent. |
| Your rules | Never edited, reordered or removed. The agent adds and removes its rules one by one (never auditctl -D, never augenrules --load). |
| File writes | Syscall rules on the sensitive paths, evaluated only on write-type system calls, recording only writes that succeeded (a user's failed attempts on /etc never reach your audit log); paths under /usr and /root are covered as those directories, and /tmp, /var/tmp and /dev/shm only when an admin lists them on the full profile. Per profile: light collects no file writes; standard records content changes (create, write, rename, link, unlink, truncate) with one rule per path; full also records chmod, chown and extended-attribute changes, a read-only open that truncates, and a unix socket bound there. Every rule costs each system call a little: measured worst case (a loop of one-byte reads and writes, every system call paying) light ~0%, standard ~0-1%, full ~4-5%; real workloads pay far less. Inherent limits: a file opened before the rules were loaded can be written through without a record, and so can writes through such a descriptor by mmap, copy_file_range or fallocate; I/O submitted through io_uring, files opened with open_by_handle_at, and a truncating read-only open made through the raw open(2) system call rather than openat (what the C library uses) are not seen either. |
| Audit settings | While its rules are loaded: backlog_limit at least 8192, and backlog_wait_time 0, so a full audit queue loses records (the kernel counts them; the agent reports the count) instead of making processes wait. Both are put back when the rules come out, unless someone changed them since. |
| Audit log | auditd writes every record the rules cause to your audit log; nothing can keep them out of it. The agent budgets them per profile: events per second per rule class (with two seconds of burst, so a connection-pool warm-up or a build start fits), a cap on how fast the log may grow, and a daily volume (light 50, standard 150, full 400 MB, and never more than half of the space auditd keeps, num_logs x max_log_file). The daily volume is measured on the audit log files themselves (what they really grew, times the agent's share of the records). On a stock auditd.conf (5 x 8 MB) that is 20 MB a day: raise max_log_file or num_logs for fuller telemetry. Process execution is audited only when auditd keeps at least 256 MB of log. On a stock auditd.conf (40 MB) auditd supplies no process starts at all: they come from the kernel's process connector, which misses the command line of a process that ends before it is read, or, without a connector, from a /proc scan every 2 seconds, which misses processes shorter than that. Short-lived processes (attack tooling often is) are seen fully only with at least 256 MB of audit log. |
| Over a limit | When one non-root user causes most of a rule class's events or log growth, only that user's events leave every one of the agent's rule classes, file writes included (30 seconds, longer on repeats; if its records still arrive a few seconds later, the class goes out for everyone; a second burst the same day keeps the user out until the day's budget has refilled), and the console names the user and how much audit log the burst wrote. The burst counts against the day's budget. Otherwise the busiest class goes out for everyone on a timer (30 seconds to 5 minutes) and comes back on its own. While a class or a user is out, process starts come from the process connector and connections from polling the connection table, which misses connections shorter than 2 seconds, other network namespaces and UDP without connect; file writes are not collected. |
| In the console | The collector is not OK while any class or user is out, with the class, the reason, since and until when; a class out for 10 minutes is shown as down (an alert). It also states, for each kind of event, where it comes from now: auditd, the process connector, polling, or not collected. |
| Not used | auditd's max_log_file_action is not ROTATE (the log would grow without bound), a space or disk action is SINGLE or HALT, the audit log's file system has under 10 % free, the failure mode is panic (-f 2), auditd is not running, auditing is off, or the rules are locked (-e 2; Lawliet never adds rules it could not take out again). max_log_file = 0 (no size limit) is refused too. All of this is checked again every minute while the agent runs. The agent then uses the kernel's process connector and /proc, and the console shows the source and the reason. That source does not see file writes, connections shorter than a few seconds, or processes that end before they are read. |
| Changes on the host | If someone removes the agent's rules (auditctl -D, an augenrules --load reload), the console shows the collector as not OK and the agent loads them again; after three removals in ten minutes it stops re-loading them and says so. |
| Log shipping | One copy per audit record group: an event caused by the agent's rules that the server confirms it stored as telemetry is not also shipped as audit.log lines; every other one (filtered, rate-limited, a full queue, refused, a failed exec) is shipped as audit.log lines, whole (all its records). Undecided groups wait up to a minute, and the shipper's saved position never passes a group it is holding, so an agent restart reads those lines again. Telemetry still queued in the agent and not yet delivered is lost on a restart. Your own audit records ship as before. |
On a default Ubuntu server, auditd is not installed: the agent uses the process connector until you install auditd (apt install auditd).
What you see: auditctl -l | grep lawliet-edr lists the agent's rules while telemetry is on, and nothing once it is off.
11.6 Procedure: uninstall the agent#
Risk: the host stops being monitored. Rollback: install it again (11.2); with the console record kept and its token revoked, it enrols as the same agent.
If the agent is protected, get an uninstall code first: Environment > Hosts > the host > Self-protection > Issue uninstall code (four-eyes; valid 1 hour, this host only). Or turn protection off for the host and wait until the console shows Off. See chapter 16.
On the host, as root, run the installer the server serves (from the bundle:
agents/install_linux.sh):sudo bash install_linux.sh --uninstall # unprotected agent sudo bash install_linux.sh --uninstall --code <code> # protected agentRemove the record in the console (chapter 10.7), or it stays listed as offline.
What you see: the services, /opt/lawliet-agent, /etc/lawliet and the agent log are removed, and so are the agent's audit rules and /etc/audit/rules.d/90-lawliet-edr.rules (11.5.1).
If it fails: "a valid host authorization code is required" means the agent is protected and the code is missing, wrong, expired or for another host. Issue a new one.
Note: a command line is visible to other users of the host and to process auditing while it runs. Issue the code just before use; it expires after one hour.
11.7 macOS#
The macOS installer works like the Linux one: take the command from Install agent > Install command > macOS (or ./lawliet token), run it with sudo in Terminal, and the host appears in Environment > Hosts (11.2). Uninstall, status and log commands are in the table. What you see for a running agent: state = running from the status command.
| Item | macOS |
|---|---|
| Command | Install agent > Install command > macOS, or the macOS section of ./lawliet token |
| Download | /api/v1/agents/download/macos |
| Program | /usr/local/lawliet-agent/lawliet-agent (arm64 for Apple silicon, amd64 for Intel) |
| Services | LaunchDaemons /Library/LaunchDaemons/com.lawliet.agent.plist and com.lawliet.watchdog.plist |
| Status | sudo launchctl print system/com.lawliet.agent | grep state |
| Log | /var/log/lawliet-agent.log |
| Uninstall | sudo bash install_macos.sh --uninstall [--code <code>] |
Differences from Linux:
- Options available:
--server,--token,--name,--sha256,--ca-cert,--insecure,--python,--local-binary,--uninstall,--code,--recovery-key,--allow-custom-commands,--no-custom-commands. There is no--reset-token,--refresh-caor--offline-package, and no macOS offline package. - To give a macOS agent a new server certificate: copy the new file over
/etc/lawliet/server-ca.pem, then runsudo launchctl kickstart -k system/com.lawliet.agent. - The binary is ad-hoc signed, not notarized. Downloaded by the installer it runs normally. A copy downloaded with a browser is quarantined; clear it with
xattr -d com.apple.quarantine <file>before running it by hand.
More detail: Linux agent reference and offline packages.