Encryption of Secrets
Introduction
Secrets are encrypted so that passwords are not stored in plaintext in either the database or regular configuration files. A master password, is stored in a special configuration file called master.key
Encryption of Secrets has been implemented for secrets in NMIS but has not been implemented for secrets in OMK opModules. At least one of your OMK opModules must be upgraded to a version that can read the encrypted secrets in NMIS.
Encryption of Secrets
Encryption of secrets stores credentials as ciphertext rather than in the clear, in both the database and the configuration files, using a master key held outside the configuration tree.
The feature has existed for several releases and was off by default. From NMIS 9.7.0 it is on by default in NMIS for new installations. Upgrades are deliberately left as they are.
What is protected
Device credentials, held per node in the database: the SNMP community, the SNMP v3 authentication password and key, the SNMP v3 privacy password and key, and the WMI password. These convert to ciphertext the first time NMIS loads each node.
Configuration secrets, held in conf/Config.nmis and listed in conf-default/PasswordFields.nmis:
Setting | What it is |
|---|---|
| MongoDB password |
| Redis password |
| SMTP password |
| LDAP bind password |
| Active Directory bind password |
| default SNMP community |
| default SNMP v3 authentication |
| default SNMP v3 privacy |
These convert as each one is used, starting with the database password on the first
connection. An encrypted value is recognisable in the file by its !! prefix.
From NMIS 9.7.1 this also covers the session cookie signing key auth_web_key and the TACACS, RADIUS and ConnectWise secrets. On 9.7.0 they're stored in plain text.
The master key
Everything depends on one file.
|
|
|---|---|
Default location |
|
Contents | one line of 256 alphanumeric characters |
Ownership and mode | the web server user, group |
Directory |
|
Created by | the NMIS installer, whether or not encryption is on |
Configured by |
|
Four rules that matter more than anything else on this page.
Back the key up with your configuration and your database. A backup of
conf/and MongoDB without the key cannot be restored. This is the single most important operational consequence of enabling encryption.Never rotate or relocate an existing key. Values encrypted under the old key stop being readable. There is no re-key path in the product.
NMIS only ever creates a key at the default path. If you point
master_key_filesomewhere else, you provision that file yourself, and NMIS will not create it, change its owner or change its mode.Changing
master_key_fileafter secrets are encrypted does not re-encrypt anything. The old values simply stop decrypting until the original path is restored.
Prerequisites
Three Perl modules must be installed:
Module | Debian and Ubuntu | RedHat family |
|---|---|---|
|
|
|
|
|
|
|
|
|
The NMIS installer has installed all three for several releases, so on an installer-built host they are already present. From 9.7.0 the installer also checks and tells you if they are missing.
Co-installed FirstWave products must be recent enough. NMIS and the OMK applications share
the code that reads encrypted secrets. If encryption is enabled on a host, **at least one FirstWave
OMK application on that host must be at the version below or newer, or nmisd will refuse to start.
From NMIS 9.7.1, if encryption of secrets is on, every OMK application on the host must be at the version below or newer, not just one.
Product | Minimum version |
|---|---|
NMIS | 9.7.0 |
opCharts | 4.10.0 |
opEvents | 4.7.0 |
opConfig | 4.9.0 |
opHA | 5.2.1 ! |
opReports | 4.7.0 |
opAddress | 2.5.0 |
! DO NOT enable Encryption of Secrets on opHA 5.2.0, opHA will not function.
The check passes when at least one installed application meets its minimum, because the applications share a common library on the host. A host with no other FirstWave applications passes automatically.
New installations
Encryption is on. Nothing to do. Record where the master key is and add it to your backups.
To install with encryption off instead, which is the pre-9.7.0 behaviour:
sudo ./installer eos=falseeos=true is also accepted, and on an upgrade it overrides whatever the existing setting is. An unrecognised value stops the install rather than guessing.
Upgrades
An upgrade does not turn encryption on. Your existing setting is preserved. This is deliberate: switching it on unattended would strand a host whose other FirstWave applications are older, and would make the master key backup-critical without warning you.
To turn it on afterwards, as root:
/usr/local/nmis9/bin/nmis-cli act=enable-eosThat stops the FirstWave daemons, encrypts the configuration secrets in one pass, and starts the daemons again. Device credentials convert as each node is next loaded. Before it writes anything it saves a plaintext copy of the configuration secrets into /usr/local/etc/firstwave, named NMIS- followed by a timestamp. That file is not cleaned up automatically. Delete it once you are satisfied the migration worked.
Turning it off
As root:
/usr/local/nmis9/bin/nmis-cli act=disable-eosThat converts the stored secrets back to plaintext and then records the setting. If it cannot decrypt something it tells you which field and leaves encryption on, rather than leaving you with a configuration that claims to be plaintext but is not.
Editing global_enable_password_encryption in Config.nmis by hand is not the same thing and will not work. The flag only controls whether new values are encrypted. Values already stored stay encrypted, and NMIS will still need the key to read them.
Checking the state
Command | Answers | Exit code |
|---|---|---|
| is encryption enabled on this install | 0 yes, 1 no |
| could encryption work here, meaning modules present and product versions acceptable | 0 yes, 1 no |
Both follow the shell convention where 0 means yes, so they can be used in scripts. Both work even when the database password cannot be decrypted, which is exactly when you need them.
nmis-cli act=show-config reports configuration values and shows secrets as <empty>, <set> or <encrypted> rather than printing them. Add showsecrets=true if you genuinely need a value back.
When something is wrong
nmisd will not start and the log shows a refusal naming encryption of secrets. That happens when encryption is on and one of three things is true: the crypto modules are missing, the master key is missing or unreadable, or every co-installed FirstWave application is below its minimum version. The message names which. There is no prompt and no way to continue past it, by design: the alternative would be running with secrets you cannot read.
The three ways out are to install the modules, upgrade the other applications, or turn encryption off deliberately with act=disable-eos.
The web interface keeps working while polling is dead. The GUI has no equivalent startup check, so a broken installation looks healthier than it is. Check nmisd rather than the dashboard.
A secret that will not decrypt is reported in the log at the point it is used, naming the field and the node, rather than silently being sent to the device as ciphertext.
Key derivation
global_password_kdf in Config.nmis controls how new secrets are written. It ships as opensslv1 and should be left alone.
Reading is unaffected by this setting: NMIS tries every derivation the installed library supports and accepts whichever validates, so changing it cannot make an existing secret unreadable. The alternative value pbkdf2 is refused in this release, because a secret written that way cannot be read by the library version bundled with the OMK applications.
Operational consequences worth planning for
There is no command that prints a stored device credential back. Runbooks and scripts that read secrets out of the configuration or the database stop working.
Support archives contain ciphertext. We cannot read secrets from a bundle you send us, which is the intended behaviour.
Configuration and node data stop being portable between hosts without the matching master key.
Restore the key first. When rebuilding a host, put the master key in place before restoring the configuration and database.