Skip to content

Debian, RPM and systemd

Each release has .deb and .rpm packages for amd64, arm64 and armv7.

Terminal window
# Debian, Ubuntu, Raspberry Pi OS
sudo apt install ./hytte_0.1.0_linux_amd64.deb
# Fedora, RHEL, openSUSE
sudo dnf install ./hytte_0.1.0_linux_amd64.rpm

The package installs:

Path What
/usr/bin/hytte The binary
/usr/lib/systemd/system/hytte.service A hardened systemd unit
/etc/default/hytte Options and secrets (kept on upgrades)
/var/lib/hytte The data directory, owned by the hytte system user

It creates the hytte user but doesn’t start the service, so you can configure it first.

/etc/default/hytte:

Terminal window
# Options for hytte (see `hytte -h`).
HYTTE_OPTS="-p 8000"
# Named Cloudflare tunnel token (needs --domain in HYTTE_OPTS and cloudflared installed).
#HYTTE_TUNNEL_TOKEN=
# Giphy API key: enables /giphy.
#GIPHY_API_KEY=

Typical HYTTE_OPTS:

Setup HYTTE_OPTS
Behind a reverse proxy -p 8000 -b 127.0.0.1 --domain chat.example.com
Named Cloudflare tunnel -b 127.0.0.1 --domain chat.example.com (set HYTTE_TUNNEL_TOKEN too)
Let’s Encrypt -p 443 -l --le-domains chat.example.com

The unit grants CAP_NET_BIND_SERVICE, so hytte can bind to ports 80 and 443 without running as root.

Terminal window
sudo systemctl enable --now hytte
sudo -u hytte hytte -d /var/lib/hytte -u ingrid # prints a setup link
journalctl -u hytte -f # logs

Run account commands as the hytte user with -d /var/lib/hytte, so they use the service’s database and files keep the right owner.

Installing a newer package replaces the binary and restarts a running service. Migrations run at startup. /etc/default/hytte and /var/lib/hytte are kept when you upgrade, and also when you remove the package.

With a binary in /usr/local/bin:

Terminal window
sudo useradd --system --home-dir /var/lib/hytte --shell /usr/sbin/nologin hytte
sudo install -d -o hytte -g hytte -m 0750 /var/lib/hytte

Then copy the unit below to /etc/systemd/system/hytte.service (adjust ExecStart to your path), create /etc/default/hytte as above, and sudo systemctl daemon-reload && sudo systemctl enable --now hytte.

[Unit]
Description=hytte, self-hosted end-to-end encrypted team chat
Documentation=https://docs.hyttechat.com
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=hytte
Group=hytte
EnvironmentFile=-/etc/default/hytte
WorkingDirectory=/var/lib/hytte
ExecStart=/usr/local/bin/hytte -d /var/lib/hytte $HYTTE_OPTS
Restart=on-failure
RestartSec=5
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=/var/lib/hytte
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictSUIDSGID=yes
RestrictRealtime=yes
RestrictNamespaces=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
SystemCallArchitectures=native
UMask=0027
[Install]
WantedBy=multi-user.target