# Device client

> One service on each device, holding one outbound connection to the realm, and keeping the security sensor and the AI tools agent running.

Each enrolled device runs one service, the device client. It opens a single connection to your realm and carries
everything over it: its own session, the security sensor's events, and the AI tools agent's traffic. Nothing on the
device listens on the network, so there is no port on your laptops for anyone to reach.

The client also looks after the parts it carries. If the security sensor (the part that watches the device's files,
settings and logs) or the AI tools agent (the part that finds the device's AI tools) stops, the client starts it
again, and it reports what it runs when you ask.

## Before you begin

- **On the device:** administrator rights to install the package and start its service.
- **In the realm:** nothing beyond [Device enrollment](../device-enrollment/). The client needs no privilege of its
  own; it is admitted by its certificate while the device's record is `active`.
- **On the network:** a direct outbound path to the device address ([Network](#network)).

## How it works

**One connection.** The client connects to the realm with the device's certificate, and the realm presents its own;
both ends check the other (mutual TLS, RFC 8446). Each kind of traffic is its own stream on that connection (HTTP/2,
RFC 9113). If the connection drops, the client connects again, waiting longer between tries.

| Stream | What it carries |
|---|---|
| The device's session | The client's version and operating system, the device's state, and the actions you run on it ([Health and actions](../../devices/health-and-actions/)) |
| The security sensor | The sensor's events up to the realm's security log ([Device event delivery](../../../detection-response/security-log/event-delivery/)), and its configuration and responses down |
| AI governance | The AI tools agent's own connection to the realm's [AI fleet](../../../ai-governance/fleet/), carried end to end |

**One standing.** Every stream is admitted only while the device's record is active. Revoking the device closes all
of them at once.

**Parts kept running.** The client starts the security sensor and the AI tools agent with itself, and stops them
with itself. It restarts a stopped part within a minute.

**Events kept across a gap.** While the device is offline, or the realm is restarting, the sensor's events wait on
the device and are sent when it reconnects. How many it keeps, and how fast it sends them, is part of the sensor's
[group configuration](../../../detection-response/sensors/group-configuration/); an overflow is reported in the
security log.

## Network

- **Outbound only.** The device opens one TLS connection to the device address, a host and port your deployment
  gives you. Nothing connects to the device.
- **No proxy.** The client connects directly; it doesn't use an HTTP proxy, and a firewall that inspects TLS breaks
  the connection, since both ends check each other's certificate. Allow the device address through untouched.
- **Your sign-in address too, for AI governance.** When a user signs in to the AI tools agent, it reaches your
  realm's sign-in address, `https://foobar.cvyuh.com/oauth2`, over HTTPS.

## Set it up

Nothing beyond [Device enrollment](../device-enrollment/). The package installs the client as one system service,
named for your deployment (for example `cvyuh-uem`):

| Platform | Service | Install folder | Log |
|---|---|---|---|
| Linux | The `cvyuh-uem` systemd service | `/var/cvyuh` | The system journal: `journalctl -u cvyuh-uem` |
| macOS | The `com.cvyuh.endpoint` launch daemon | `/Library/Cvyuh` | `/Library/Cvyuh/logs/uem.log` |

On macOS the installer starts the service; on Linux, start it with `sudo systemctl enable --now cvyuh-uem`. The AI
tools agent is installed beside the client as `bin/cvyuh-aig`, and the client starts it; it isn't a service of its
own.

## Limits and defaults

| What | Value |
|---|---|
| Connections per device | One, outbound |
| A stopped sensor or AI tools agent | Started again within a minute |
| Events kept while offline | As the sensor's [group configuration](../../../detection-response/sensors/group-configuration/) sets |
| Certificate | 365 days; past it the client stops connecting until the device is enrolled again |

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| The device never shows `connected` | The service isn't running | Linux: `sudo systemctl enable --now cvyuh-uem`. macOS: `sudo launchctl kickstart -k system/com.cvyuh.endpoint` |
| It still doesn't connect, and the log shows connection errors | No direct path to the device address: a firewall, a proxy, or TLS inspection | Allow the device address's host and port outbound, untouched ([Network](#network)) |
| The log says `re-enrol: certificate expired` | Its certificate's year is up | [Enroll a device again](../../guides/enroll-a-device-again/) |
| It connects, then is refused at once | The device is revoked, or being removed | Read its record: `status` says which ([Device revocation](../../revoke-and-remove/revocation/)) |
| No security events from a connected device | The sensor isn't running | Ask it with the `status` action, and restart it with `restart-dar` ([Health and actions](../../devices/health-and-actions/)) |

## Audit record

The client writes nothing to the realm's audit trail; its own record is in its log, above.

## Good to know

- **Named by its certificate.** The realm knows the device by the name in its certificate, never by what the device
  says about itself.
- **Only known actions.** The client runs only the actions it knows; anything else is refused, never guessed at.
- **An expired certificate stops it connecting.** Past its certificate's end the client connects to nothing until
  the device is enrolled again; renewal is [planned](../whats-next/#certificate-renewal).
- **Uninstalling stops it.** Removing the package stops the client and removes it with the sensor and the AI tools
  agent. The device's record stays in the realm until you remove it; see
  [Device removal](../../revoke-and-remove/removal/).

## Related

- [Device enrollment](../device-enrollment/): how the client gets its certificate.
- [Health and actions](../../devices/health-and-actions/): what the client reports, and what you can ask of it.
- [Device revocation](../../revoke-and-remove/revocation/): cutting the connection off.
