Black Branch/Docs
All sections

Before you start

This page is for someone with a server ready, a few minutes before installing. After it, you will have checked that the server fits and that your account can use sudo, and made the two decisions you cannot change later. Why each requirement exists is on What you need; read that first if you have not.

What you need to be comfortable with

You do not set anything up by hand. The installer creates every password and secret for you and saves them in one file on your server, /opt/blackbranch/.env, readable only by root. You can read it any time with sudo cat /opt/blackbranch/.env.

The one thing you must keep safe yourself is your recovery sheet: setup shows it once, and it holds the passphrase that unlocks your backups.

You change settings through the setup pages, the Admin Panel, or sudo blackbranch set, which checks the value and puts the old one back if the site does not come back up. You can edit files by hand; these pages ask you to only for one optional setting, where the server sends its own alerts.

It is still a server install. It assumes you can:

You do not need to know Docker, Linux administration, Matrix or web servers: the installer and the blackbranch command handle those. If the list above is new to you, a friend who has run a server before can sit with you for the hour. You can also book a paid setup call with the project (ask in the Discord): you type and keep every password, and the other person reads along.

Preview note: these pages are written so that someone new to servers can install from them alone. The project has installed a release end to end on fresh public servers through both front doors, the Cloudflare tunnel and direct mode, and taken a direct-mode server through an update; installs by first-time owners are what these previews are for.

The server, in one line

Debian stable or Ubuntu LTS, x86-64, at least 4 GB of memory, 2 cores, 40 GB of disk and an IPv4 route out, with an account that can use sudo. Full table and reasons: What you need: a server.

Check your account can use sudo

You install as your ordinary user, with sudo in front of the installer. Signing in as root works too.

  1. Sign in to the server over SSH.
  2. Run sudo -v. It asks for your password and then prints nothing. That means you are ready.
  3. If it says your user "is not in the sudoers file", or sudo: command not found, your account cannot install anything yet:
    • on a rented server, use the account the provider set up for you, or ask the provider;
    • on your own machine, sign in as root once, run apt install sudo (Debian leaves it out when a root password was set during its install) and usermod -aG sudo <your user>, then sign out and in again.

If your server came with only a root login, make an ordinary user first: see Making a sudo user.

Check the server fits

These four commands show what to check. None of them changes anything.

Command What to look for
cat /etc/os-release ID=debian or ID=ubuntu. The installer refuses anything else. It does not check the version number, so pick a current Debian stable or Ubuntu LTS yourself.
uname -m x86_64. ARM servers are refused.
free -h About 4 GB under total. A server sold as "4 GB" reports a little less and still passes. The installer stops below 3,600 MiB, which free -h shows as about 3.5Gi. The Doctor checks the same line later.
df -h / At least 40 GB in size, with most of it free.

The installer checks the system, the processor, the memory and whether it can reach the image registry (ghcr.io, IPv4 only) before it installs Docker or changes anything. If Docker is already installed, its Compose plugin must be version 2.20 or newer (docker compose version). The installer only prints the free disk space; it does not stop on a small disk, so check that one yourself.

Two decisions you cannot change later

The domain

Pick the domain your community will live at, for example example.com. The install uses three names on it: example.com for the site, api.example.com for its API, and matrix.example.com for the homeserver.

⚠ The domain is permanent. The installer refuses to run again with a different domain, and there is no command to rename an install. Why: What you need: a domain.

The front door

The front door is how visitors reach your server:

Both front doors are tested end to end. The installer refuses to switch an existing install from one front door to the other, so treat this choice as permanent too. The comparison table is on What you need.

Have these open before you start

What runs where: Linux, Docker and the host

Almost everything runs in Docker containers: the site, the chat service and the ingest service, the database, the homeserver and its sign-in service, the router, the backup tool and, in tunnel mode, cloudflared. A few pieces run on the server itself, which is why the installer is Linux-only:

On the host Why it is not in a container
Docker Engine (installed by the installer, from Docker's own Debian and Ubuntu packages) It runs all the containers. It is the normal Docker that runs as root, not "rootless" Docker.
The blackbranch command (/usr/local/bin/blackbranch) It has to work when the site is down, so it cannot live inside the site. The server needs no Node.js.
systemd units and timers The nightly backup, the weekly restore check, the nightly update check, finishing an interrupted update at boot, and the watcher that carries out the site's requests to the server.
unattended-upgrades Installs the operating system's security updates by itself.

So the installer needs a Linux with apt, systemd and /etc/os-release:

Your account: a sudo user, not root

Many providers hand you a server with only a root login; others give you an ordinary account with sudo. Either works. The installer checks one thing about who runs it: that it has root's rights. Without them it stops with "run as root: sudo …".

It needs those rights to install packages and Docker, to write /opt/blackbranch, /usr/local/bin/blackbranch and the systemd units, to switch on automatic security updates, and to add a swap file when it builds. It does not create a user of its own: the services run inside their containers as their own built-in users.

Why every command in these docs starts with sudo

These docs assume you sign in as an ordinary user. After the install, almost everything you type on the server needs root's rights, so every command is written with sudo in front:

If you work as root (you signed in as root, or ran sudo -i), leave sudo off; the commands work the same. sudo asks for your password the first time and then remembers it for a few minutes. The Doctor's fix lines and the setup hints print their commands with sudo too, so you can copy them as they are.

Making a sudo user (on a fresh server with only root)

Signed in as root:

  1. adduser casey (any name). It asks for a password, which sudo will ask for later.
  2. usermod -aG sudo casey, which puts the new user in the sudo group.
  3. From your own computer, copy your SSH key to the new user: ssh-copy-id casey@<server address>. If you have no key yet, make one first with ssh-keygen -t ed25519.
  4. Still on your own computer, open a new terminal and sign in as the new user: ssh casey@<server address>. It should not ask for the account's password (only, perhaps, for your key's passphrase).
  5. In that new session, run sudo -v. It asks for casey's password and then prints nothing. If it says casey "is not in the sudoers file", step 2 did not take: fix it from the root session, then sign out and in again as casey.

Do not go further until steps 4 and 5 both work. The root session you started in is your way back if they do not.

Turning off password and root sign-in (optional)

This is optional but worth it. A mistake here can lock you out of your own server, so read every step before you start, and keep the session you are signed in with open the whole time.

  1. Confirm in a second terminal that key sign-in works as your sudo user (ssh casey@<server address>), and that sudo -v works there. Never turn off passwords or root before this works.

  2. Find where your server already sets these options. On Ubuntu and Debian, SSH reads every file in /etc/ssh/sshd_config.d/ first, and the first value it reads wins. Cloud images often ship a file there, such as 50-cloud-init.conf with PasswordAuthentication yes. List them with sudo grep -ri 'passwordauthentication\|permitrootlogin' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/.

  3. Put your settings in a file that is read first: sudo nano /etc/ssh/sshd_config.d/00-hardening.conf, with these two lines, then save (Ctrl+O, Enter) and leave nano (Ctrl+X). The 00- makes it the first file read.

    PasswordAuthentication no
    PermitRootLogin no
    
  4. Check the configuration: sudo sshd -t. It prints nothing when all is well. If it prints an error, fix the file and run it again.

  5. Check what SSH will use: sudo sshd -T | grep -E '^(passwordauthentication|permitrootlogin)' should print passwordauthentication no and permitrootlogin no.

  6. Apply it: sudo systemctl reload ssh. On Ubuntu 24.04 and later SSH may start on demand; if this says the unit is not active, that is fine: the next sign-in reads the new settings.

  7. In a third terminal, sign in again as casey. It must work. Only then close the old sessions.

If the new sign-in fails, use the session you kept open to delete the file (sudo rm /etc/ssh/sshd_config.d/00-hardening.conf) and run sudo systemctl reload ssh again. If every session is closed and you cannot get in, use your provider's web console (often called "Console", "VNC" or "Recovery" in its dashboard), which reaches the server without SSH, and undo the change there.

Ubuntu's OpenSSH guide explains the settings, and the sshd_config manual explains why the first value wins.

Next: Putting your domain on Cloudflare (tunnel mode), or Installing (direct mode).

← Install