On a Linux server without Docker, run kaisar run as a systemd service under its own system user. The node key is kept in a file (0600) in /var/lib/kaisar-node (0700), readable only by that user, and survives restarts.
Before you start
- Linux with systemd and a machine ID in
/etc/machine-id. If it is missing, create one once:sudo systemd-machine-id-setup(error KN-1006 otherwise). - The
kaisarbinary for Linux from Downloads, checked as shown in Verify your download, once it is listed under Builds. - The node gateway address [TBA], written as
<gateway>below.
Install
Run every step as root.
- Copy the binary:
sudo install -m 0755 kaisar-<version>-x86_64-unknown-linux-gnu /usr/local/bin/kaisar- Create the system user:
sudo useradd --system --no-create-home --shell /usr/sbin/nologin kaisar-node- Create the config folder:
sudo install -d -m 0750 -o root -g kaisar-node /etc/kaisar-node- Create
/etc/kaisar-node/kaisar-node.env(ownerroot:kaisar-node, mode 0640) with the gateway and the 6-digit code from Kaisar App › Node Hub › Add node. The code is valid for 10 minutes:
KAISAR_GATEWAY_URL=<gateway>
KAISAR_RUN_ARGS=--link-code <code>- Create
/etc/systemd/system/kaisar-node.service:
[Unit]
Description=Kaisar Node
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=600
StartLimitBurst=5
[Service]
Type=exec
User=kaisar-node
Group=kaisar-node
EnvironmentFile=/etc/kaisar-node/kaisar-node.env
Environment=KAISAR_NODE_CONFIG_DIR=/var/lib/kaisar-node
StateDirectory=kaisar-node
StateDirectoryMode=0700
ExecStart=/usr/local/bin/kaisar run $KAISAR_RUN_ARGS
Restart=on-failure
RestartSec=15s
KillSignal=SIGTERM
TimeoutStopSec=30s
KeyringMode=private
NoNewPrivileges=yes
CapabilityBoundingSet=
AmbientCapabilities=
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
ProtectProc=invisible
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
RemoveIPC=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~@privileged
SystemCallErrorNumber=EPERM
UMask=0077
[Install]
WantedBy=multi-user.target- Reload systemd:
sudo systemctl daemon-reload- Enable and start the service:
sudo systemctl enable --now kaisar-node- Follow the log until it shows "Open Kaisar App to confirm this machine":
journalctl -fu kaisar-node- Choose Confirm link in Kaisar App. The log shows "Linked · this machine is now in your Node Hub", then the node starts running.
- Remove the
KAISAR_RUN_ARGSline from/etc/kaisar-node/kaisar-node.env. A linked machine ignores the code, but do not leave an old code behind.
Check the machine
Run kaisar doctor as the service user, with the same data folder. It works while the service runs:
sudo -u kaisar-node env KAISAR_NODE_CONFIG_DIR=/var/lib/kaisar-node KAISAR_GATEWAY_URL=<gateway> kaisar doctorUpdate
- Download the new
kaisarbinary for Linux and its.minisigfile from Downloads. - Verify it:
kaisar verify-release <file> <file>.minisig- Stop the service:
sudo systemctl stop kaisar-node- Replace the binary:
sudo install -m 0755 <file> /usr/local/bin/kaisar- Start the service:
sudo systemctl start kaisar-node- Check it with
kaisar --versionand thekaisar doctorcommand above. The key and profile in/var/lib/kaisar-nodestay: no new code is needed.
Stop, restart, unlink
- Stop:
sudo systemctl stop kaisar-node. The service gets 30 seconds to hand back held tasks. - If linking fails (wrong or expired code), systemd stops retrying after 5 attempts in 10 minutes. Put a new code in the env file, then
sudo systemctl restart kaisar-node. - Unlink this machine: stop the service, then run the command below. It revokes the node key and removes the key file. You can also remove the machine in Kaisar App › Node Hub.
sudo -u kaisar-node env KAISAR_NODE_CONFIG_DIR=/var/lib/kaisar-node KAISAR_GATEWAY_URL=<gateway> kaisar unlinkUninstall
Run every step as root.
- Stop the service and unlink the machine with the
kaisar unlinkcommand above, or remove it in Kaisar App › Node Hub. - Disable the service:
sudo systemctl disable --now kaisar-node- Remove the unit file:
sudo rm /etc/systemd/system/kaisar-node.service- Reload systemd:
sudo systemctl daemon-reload- Remove the config folder:
sudo rm -r /etc/kaisar-node- Remove the data folder (profile, and the key file if you did not unlink):
sudo rm -r /var/lib/kaisar-node- Remove the binary:
sudo rm /usr/local/bin/kaisar- Remove the service user:
sudo userdel kaisar-nodeHow the service is locked down
The unit runs without root, without capabilities and with ProtectSystem=strict: the only folder it can write to is /var/lib/kaisar-node. It has no access to home folders or devices, and a private /tmp. Do not add ProcSubset=pid: Kaisar Node reads its own mount table to tell whether it runs in a container.
Anyone with root access to the server can read the key file. Use an encrypted disk and do not back up /var/lib/kaisar-node off the machine.