Debian, RPM and systemd
From the package
Section titled “From the package”Each release has .deb and .rpm packages for amd64, arm64 and armv7.
# Debian, Ubuntu, Raspberry Pi OSsudo apt install ./hytte_0.1.0_linux_amd64.deb# Fedora, RHEL, openSUSEsudo dnf install ./hytte_0.1.0_linux_amd64.rpmThe 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.
Configure
Section titled “Configure”/etc/default/hytte:
# 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.
Start and create the first account
Section titled “Start and create the first account”sudo systemctl enable --now hyttesudo -u hytte hytte -d /var/lib/hytte -u ingrid # prints a setup linkjournalctl -u hytte -f # logsRun account commands as the hytte user with -d /var/lib/hytte, so they use the service’s database and files keep the right owner.
Upgrade and remove
Section titled “Upgrade and remove”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.
By hand
Section titled “By hand”With a binary in /usr/local/bin:
sudo useradd --system --home-dir /var/lib/hytte --shell /usr/sbin/nologin hyttesudo install -d -o hytte -g hytte -m 0750 /var/lib/hytteThen 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 chatDocumentation=https://docs.hyttechat.comAfter=network-online.targetWants=network-online.target
[Service]Type=simpleUser=hytteGroup=hytteEnvironmentFile=-/etc/default/hytteWorkingDirectory=/var/lib/hytteExecStart=/usr/local/bin/hytte -d /var/lib/hytte $HYTTE_OPTSRestart=on-failureRestartSec=5
AmbientCapabilities=CAP_NET_BIND_SERVICECapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yesProtectSystem=strictReadWritePaths=/var/lib/hytteProtectHome=yesPrivateTmp=yesPrivateDevices=yesProtectKernelTunables=yesProtectKernelModules=yesProtectKernelLogs=yesProtectControlGroups=yesProtectClock=yesProtectHostname=yesRestrictSUIDSGID=yesRestrictRealtime=yesRestrictNamespaces=yesLockPersonality=yesMemoryDenyWriteExecute=yesSystemCallArchitectures=nativeUMask=0027
[Install]WantedBy=multi-user.target