Skip to content

First Run Setup

Arthu Santiago edited this page Nov 30, 2026 · 1 revision

First-Run Setup

A fresh installation has no users. The first-run setup creates the first one, the administrator (root), and activates the second authentication factor (2FA) for that account. This page explains why the setup is protected by a token, walks through the two steps and lists the errors you may see.

Why there is a token

The setup is reachable without logging in while the installation has no configured user. Without protection, whoever opened a newly installed KeyAnyWhere first would become its administrator, and could read the 2FA secret of that account. That is why it opens only with the CONFIG_INICIAL_TOKEN you generated in Environment Variables, passed once in the address.

Before you start

The site must answer over HTTPS, as in Web Server and HTTPS, and you need an authenticator app on your phone (any TOTP app, such as Aegis, Google Authenticator or 1Password).

1. Open the setup address

This command prints the address with your token. Open it in your browser.

echo "https://$(sudo grep -oP '(?<=ServerName ).*' /etc/apache2/sites-available/keyanywhere.conf)/users/config-inicial?token=$(sudo grep -oP "(?<=^CONFIG_INICIAL_TOKEN=').*(?='$)" /etc/keyanywhere/keyanywhere.env)"

The token only needs to be in the address once: after it is checked, it is kept in the browser session and opens both steps.

2. Create the administrator

The first screen says it will create the first user of the system, who is also the administrator. Fill in the name, the e-mail (used to log in) and a strong password, then save.

3. Activate the second factor

2FA is mandatory for every account. The second screen shows a QR code.

  1. Scan the QR code with your authenticator app. If you can't scan it, the section below it shows the key, the key type (time-based) and the name to type in the app instead.
  2. Only after the app shows a 6-digit code for KeyAnyWhere, click Completar configuração (Complete setup). The QR code and the key are not shown again.

4. Check that it worked

Open https://<your domain>/ and log in with the e-mail, the password and the current code from the app. You land on the home page, Minha Segurança (My Security).

5. Remove the token

After the setup, the token no longer opens anything. You can delete it from the environment file:

sudo sed -i '/^CONFIG_INICIAL_TOKEN=/d' /etc/keyanywhere/keyanywhere.env
sudo systemctl restart apache2

Errors you may see

Message Cause What to do
"A configuração inicial não foi autorizada" (The first-run setup was not authorized), HTTP 403 No token in the address, a wrong token, or a token shorter than 32 characters. Print the address again with the command in step 1.
You are sent to the login page The installation is already configured. Log in. To create more users, see Administration.

Your installation is ready

That's the end of the production path. Next:

Clone this wiki locally