Repository navigation
Generating Security Keys
KeyAnyWhere needs three secrets, all generated by you and never copied from an example. This page explains what each one protects, what happens if it changes or leaks, and how to generate it. In the production path, the next page (Environment Variables) generates all three for you while it creates the environment file; come back here when you need to understand or replace one of them.
Each secret has a different job, and losing each one has a different cost. Read this table before deciding where to keep the copies.
| Variable | What it protects | If it changes | If it leaks |
|---|---|---|---|
KEY_CRIPTOGRAFIC |
Encrypts every stored title, username, password, link, note, category name and 2FA secret (libsodium secretbox). |
Every stored secret becomes unreadable. There is no recovery and no re-encryption tool. Never change it on a running installation. | Whoever also has a copy of the database can decrypt everything. |
SECURITY_SALT |
Signs cookies and CSRF tokens (CakePHP Security.salt). At least 32 characters, or the application refuses to start. |
Users are logged out and their CSRF cookies are renewed on the next page they open. Nothing is lost. | Cookies can be forged. Replace it. |
CONFIG_INICIAL_TOKEN |
Opens the first-run setup, which creates the administrator. At least 32 characters. | Only matters before the setup is done. | Only matters before the setup is done. After that, you can delete it. |
Warning
Keep a copy of KEY_CRIPTOGRAFIC outside the server, in a place that does not depend on KeyAnyWhere itself (a different password manager, a printed copy in a safe). A database backup is useless without it. See Backup and Restore.
Use these commands to generate a single secret, for example to replace a leaked SECURITY_SALT. Each one prints a new random value.
KEY_CRIPTOGRAFIC (64 hexadecimal characters, a libsodium key):
php -r 'echo sodium_bin2hex(sodium_crypto_secretbox_keygen()), PHP_EOL;'SECURITY_SALT (64 hexadecimal characters):
php -r 'echo bin2hex(random_bytes(32)), PHP_EOL;'CONFIG_INICIAL_TOKEN (64 hexadecimal characters):
php -r 'echo bin2hex(random_bytes(32)), PHP_EOL;'To replace a value in production, edit it in /etc/keyanywhere/keyanywhere.env and restart Apache:
sudoedit /etc/keyanywhere/keyanywhere.envsudo systemctl restart apache2Source code · Issues · Releases · Packagist · Online demo · Hosted edition
1. Getting started
2. Installing in production
- Overview
- Preparing the Server
- Installing KeyAnyWhere
- File Permissions
- Generating Security Keys
- Environment Variables
- Configuration Files
- Database Setup
- Insecure Password Catalog
- Web Server and HTTPS
- First-Run Setup
3. Operating your installation
4. Using KeyAnyWhere
5. Security
6. Development
7. Extending