Manage KMS using CLI
Explore commands for managing Key Management System (KMS) integration with the WEKA system using the CLI.
Using the CLI, you can:
Configure the KMS
Command: weka security kms set
Use this command to add or update the KMS configuration. For HashiCorp Vault, you can configure a single cluster-wide encryption key or enable per-filesystem encryption keys.
Per-filesystem encryption requires using Vault's AppRole authentication method, which you configure using the --role-id and --secret-id parameters.
Run the following command to establish a connection between the WEKA system and the configured Vault KMS.
weka security kms set <type> <address> <key-identifier> [--token token] [--role-id role-id] [--secret-id secret-id] [--kubernetes-role kubernetes-role] [--namespace namespace]
[--client-cert client-cert] [--client-key client-key] [--ca-cert ca-cert] [--transit-path transit-path] [--auth-path auth-path] [--convert-to-cluster-key-on-fs]
Parameters
type*
Type of the KMS.
Values: vault or kmip
address*
KMS server address.
Values:
URL for vault
hostname:port for kmip
key-identifier*
Key name for vault
UID for kmip to secure filesystem keys.
token
The API token for authenticating with a HashiCorp Vault KMS.
This parameter applies only to Vault and is used for cluster-wide encryption. It cannot be used with the role-id or secret-id parameters, which are used for AppRole authentication.
The access token must have the following permissions in Vault:
Read access to
transit/keys/<master-key-name>Write access to
transit/encrypt/<master-key-name>andtransit/decrypt/<master-key-name>Permissions for
/transit/rewrapandauth/token/lookup
role-id
Role ID for HashiCorp Vault's AppRole authentication method, which is provided by the Vault administrator. This parameter must be used with secret-id and cannot be used with token.
secret-id
Secret ID for HashiCorp Vault's AppRole authentication, which is provided by the Vault administrator. This parameter must be used with role-id. Alternatively, you can set this value using the
WEKA_KMS_SECRET_ID environment variable.
kubernetes-role
The Kubernetes role used for authentication with HashiCorp Vault.
namespace
The namespace name in HashiCorp Vault.
Namespace names must not end with "/", avoid spaces, and refrain from using reserved names like root, sys, audit, auth, cubbyhole, and identity.
client-cert
Path to the client certificate PEM file.
Must permit encrypt and decrypt permissions.
Mandatory for kmip .
Prohibited for vault.
client-key
Path to the client key PEM file.
Mandatory for kmip .
Prohibited for vault.
ca-cert
Path to the CA certificate PEM file.
Optional for kmip.
Prohibited for vault.
transit-path
The custom path where the HashiCorp Vault transit secrets engine is enabled.
auth-path
The custom path where the HashiCorp Vault authentication method is enabled.
convert-to-cluster-key-on-fs
Convert all encrypted filesystems to use cluster key.
Obtain role-id and secret-id from HashiCorp Vault
role-id and secret-id from HashiCorp VaultUse this procedure when configuring HashiCorp Vault with AppRole authentication. This method is required for per-filesystem encryption and is an option for cluster-wide encryption. The Vault administrator provides the role-id and secret-id needed for access.
Recommendation: use batch tokens for per-filesystem encryption
For per-filesystem encryption, it is recommended to configure the AppRole with batch tokens to ensure optimal performance and scalability in your HashiCorp Vault environment.
Unlike standard service tokens, which generate a new lease for each authentication request, batch tokens are designed for high-volume, automated workflows. They do not create new leases upon use, which is critical for maintaining efficiency in environments with many filesystems.
While batch tokens can be used multiple times, their lifetime is limited by a Time-to-Live (TTL). It is recommended to set a short TTL (for example, 20 minutes) to align with security best practices.
Batch tokens are not single-use but are limited by their TTL, and they do not create new leases upon use, which prevents this scalability problem. To implement this, create your AppRole with the token_type set to batch.
For more information, refer to the official HashiCorp Vault documentation.
Disclaimer: The following example is provided as a courtesy to illustrate possible integration with HashiCorp Vault and is not part of our product.
Set up roles for cluster access
Enable AppRole authentication:
Role for cluster:
Retrieve the role-id:
Role for Key1:
Retrieve the role-id and generate a secret-id:
Examples
Setting the WEKA system with a HashiCorp Vault KMS for cluster-wide encryption:
Setting the WEKA system with a HashiCorp Vault KMS for per-filesystem encryption:
Setting the WEKA system with a KMIP complaint KMS (SmartKey example):
View the KMS configuration
Command: weka security kms
Use this command to show the details of the configured KMS.
Remove the KMS configuration
Command: weka security kms unset
Use this command to remove the KMS from the WEKA system. It is only possible to remove a KMS configuration if no encrypted filesystems exist.
To force remove a KMS even if encrypted filesystems exist, use the --allow-downgrade attribute. In such cases, the encrypted filesystem keys are re-encrypted with local encryption and may be compromised.
Rewrap filesystem keys
Command: weka security kms rewrap
If the KMS key is compromised or requires rotation, the KMS administrator can rotate the key in the KMS. In such cases, this command is used to re-encrypt the encrypted filesystem keys with the new KMS cluster key.
weka security kms rewrap [--new-key-uid new-key-uid] [--all] [--convert-to-cluster-key-on-fs]
Parameters
new-key-uid*
Unique identifier for the new key to be used to wrap filesystem keys.
Mandatory for kmip only.
Do not specify any value for vault.
all
Rewrap all the filesystem encryption keys. Applicable when using HashiCorp Vault for per-filesystem encryption keys.
Without the --all option, the command re-encrypts only the keys of filesystems that use the cluster key for encryption.
convert-to-cluster-key-on-fs
Convert all encrypted filesystems to use the KMS cluster key.
Unlike HashiCorp Vault KMS, re-wrapping a KMIP-based KMS necessitates generating a new key within the KMS rather than rotating the existing one. Therefore, it is essential to retain the old key in the KMS to ensure the decryption of older Snap-to-Object snapshots.
Set up vault configuration
Enable 'Transit' secret engine in vault
The WEKA system uses encryption-as-a-service capabilities of the KMS to encrypt/decrypt the filesystem keys. This requires the configuration of Vault with the transit secret engine with this command:
The expected output is:
Set up a master key for the WEKA system
Once the transit secret engine is set up, a master key for use with the WEKA system must be created with this command:
The expected output is:
Related information:
Vault transit secret-engine documentation
Create a policy for master key permissions
Create a
weka_policy.hclfile with the following content:
This limits the capabilities so there is no permission to destroy the key, using this policy. This protection is important when creating an API token.
Create the policy using the following command:
Obtain an API token from the vault
Authentication from the WEKA system to Vault relies on an API token. Since the WEKA system must always be able to communicate with the KMS, a periodic service token must be used.
Verify that the
tokenauthentication method in Vault is enabled. This can be performed using the following command:
The expected output is:
To enable the token authentication method use the following command:
Log into the KMS system using any of the identity methods Vault supports. The identity must have permission to use the previously set master key.
Create a token role for the identity using the following command:
Generate a token for the logged-in identity using the following command:
The expected output is:
For more information on obtaining an API token, refer to Vault Tokens documentation.
The WEKA system does not automatically renew the API token lease. It can be renewed using the Vault CLI/API. It is also possible to define a higher maximum token value (max_lease_ttl)by changing the Vault Configuration file.
Obtain a certificate for a KMIP-based KMS
Each KMS employs a unique process for obtaining a client certificate and key and configuring it through the KMS. The certificate is generated using OpenSSL and utilizes a UID obtained from the KMS.
Example:
Refer to the specific KMS documentation to create a certificate and associate it with the WEKA cluster within the KMS, ensuring it has the necessary privileges for encryption and decryption.
Last updated