KoskenDocs Open the app

Install the agent

The install command, what it puts on the machine, what the machine needs, and how to check that the agent runs.

3 min readUpdated on Español

On this page
  1. The install command
  2. Requirements
  3. What the install does
  4. Check that the agent runs
  5. The enrollment key
  6. Update or remove the agent

After this guide you can install the Kosken agent on a Linux machine, know what it changes, and check that it runs.

The install command

Kosken makes the command when you click Connect machine. See Quickstart. The command has this form:

curl -fsSL https://acme.workspace.kosken.ai/enroll/<key> | sudo sh

The command downloads a script from the address of your workspace and runs it as root. Run it on the machine that you named in Kosken.

To read the script before it runs:

  1. Download it to a file:
    curl -fsSL https://acme.workspace.kosken.ai/enroll/<key> -o kosken-install.sh
  2. Read the file:
    less kosken-install.sh
  3. Run it:
    sudo sh kosken-install.sh

Requirements

  • Linux with systemd. The script stops on any other system.
  • An amd64 or arm64 CPU.
  • Root, or a user who can use sudo.
  • The programs curl, sha256sum, openssl and base64. OpenSSL must be version 3 or later, because the signature check uses Ed25519.
  • Outbound HTTPS (port 443) to the address of your workspace, to releases.kosken.ai and to agents.kosken.ai. The agent opens no listening port, so no inbound rule is necessary.
  • A correct clock. When the clock is wrong by more than 2 minutes, the executor refuses orders.

A machine that runs inside an application container stays in audit mode, because Kosken makes changes on the host that runs it. An LXC container with systemd can leave audit mode. See Modes.

What the install does

  1. It downloads the release manifest from releases.kosken.ai and checks its signature.
  2. It downloads kosken-agent, kosken-exec and restic, and checks the SHA-256 hash of each file against the manifest. It stops if a hash does not match.
  3. It places the programs in /usr/local/lib/kosken/. The link /usr/local/lib/kosken/current points to the version that runs.
  4. It creates the group kosken and the system user kosken-agent, with no login shell.
  5. It creates /etc/kosken for the configuration and /var/lib/kosken for the keys, the state and the verified recipes.
  6. It writes two systemd units, enables them and starts them.
UnitRuns asNetworkJob
kosken-agent.servicekosken-agent, with no privilegesOutbound onlyTalks to Kosken, reports facts and signals, runs the monitors. It never runs a command.
kosken-exec.servicerootNone. A local socket onlyThe executor. It verifies the signature of each order and recipe, then runs the recipe steps.

The agent unit has a memory limit of 256 MB and a CPU limit of 10%. The executor unit sets PrivateNetwork=yes and RestrictAddressFamilies=AF_UNIX. A compromised agent cannot make the executor run an unsigned recipe. See How Kosken keeps a machine safe and the whitepaper.

restic is the backup program that Kosken uses. See Backups.

Check that the agent runs

In Kosken, the Machines page shows the machine as Online, and the Agent column shows its version.

On the machine:

  1. Check the two units:
    systemctl status kosken-agent kosken-exec
  2. Show the state of the agent: the server, the versions, the channel, the last heartbeat and the executor.
    sudo /usr/local/lib/kosken/current/kosken-agent status
  3. If a value is wrong, run the checks. They test DNS, TLS 1.3 to Kosken, the clock offset, the mode of the private key and the executor socket. Each line starts with ok: or fail:.
    sudo /usr/local/lib/kosken/current/kosken-agent doctor
  4. Read the log of the agent:
    journalctl -u kosken-agent

For an agent that was online and stopped, see An agent that is offline.

The enrollment key

The key in the command connects one machine to your workspace. You need write access to make a key.

  • The page shows the key one time. Copy the command before you click Done.
  • The key expires one hour after Kosken makes it. The page shows the time in The key expires.
  • The key works one time. After the agent enrolls, it uses its own certificate, and the key stops working.
  • A new key for the same machine stops the old key.

When nobody runs the command in time, the machine stays Pending with the badge Key expired. To get a new command:

  1. Open the machine.
  2. In the message The install command expired., click New enrollment key. A pending machine also has this button in the Settings tab, under Install command.
  3. Copy the new command and run it on the machine.

A pending machine with an expired key is deleted by itself after 7 days.

Update or remove the agent

See Update the agent and remove it.

Something here does not match the app? Tell us