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:
- rent a server (or prepare a Linux machine) and sign in to it over SSH from a terminal;
- copy and paste commands into that terminal, and read what they print when something stops;
- buy a domain and change its nameservers or DNS records;
- keep a secret (the backup passphrase) in a password manager.
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.
- Sign in to the server over SSH.
- Run
sudo -v. It asks for your password and then prints nothing. That means you are ready. - 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) andusermod -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:
tunnel(the default): a Cloudflare tunnel. Your server connects out to Cloudflare, so no ports need to be open and it works behind a home router. Your domain must already be on a Cloudflare account: see Putting your domain on Cloudflare.direct: visitors connect straight to the server's public address, and the server gets its own certificates from Let's Encrypt. Ports 80 and 443 must reach the server, and the three names must point at it before you install (see Direct mode).
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.
Recommended: the Cloudflare tunnel, unless you already run your own DNS and want no third party between your visitors and your server.
Have these open before you start
- A password manager, or another safe place off the server, for the backup passphrase. The setup pages show it once.
- If backups will go to a storage bucket: the bucket already created, and its access key id and secret key. If they will go to another server over SFTP: that account's user name and address.
- A browser signed in to your Cloudflare account (tunnel mode), and to the accounts you will connect.
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:
- Other Linux distributions (Fedora, Arch, Alpine) are refused.
- ARM servers (
aarch64, such as a Raspberry Pi or an ARM cloud server) are refused. - macOS and Windows cannot be the server. Docker Desktop on them does not provide the systemd and
aptthe install relies on. Windows' Linux subsystem (WSL) reports itself as Ubuntu, but it is not a server that stays on, and it is untested.
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:
blackbranch: every subcommand excepthelpreads/opt/blackbranch/.envor changes the install. Withoutsudoit tells you to run it withsudo.dockeranddocker compose: only root (or a member of thedockergroup, which amounts to root) may use the normal Docker.systemctlchanges, and anything inside/opt/blackbranch: the folder is closed to every user but root, so evencd /opt/blackbranchfails withoutsudo.
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.
Recommended: sign in as an ordinary user with
sudo, using an SSH key rather than a password.
Making a sudo user (on a fresh server with only root)
Signed in as root:
adduser casey(any name). It asks for a password, whichsudowill ask for later.usermod -aG sudo casey, which puts the new user in thesudogroup.- 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 withssh-keygen -t ed25519. - 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). - 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.
-
Confirm in a second terminal that key sign-in works as your sudo user (
ssh casey@<server address>), and thatsudo -vworks there. Never turn off passwords or root before this works. -
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 as50-cloud-init.confwithPasswordAuthentication yes. List them withsudo grep -ri 'passwordauthentication\|permitrootlogin' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/. -
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). The00-makes it the first file read.PasswordAuthentication no PermitRootLogin no -
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. -
Check what SSH will use:
sudo sshd -T | grep -E '^(passwordauthentication|permitrootlogin)'should printpasswordauthentication noandpermitrootlogin no. -
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. -
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