Ce contenu n'est pas disponible dans la langue sélectionnée.
Working with vaults in Identity Management
Storing and managing sensitive data in IdM
Abstract
Providing feedback on Red Hat documentation Copier lienLien copié sur presse-papiers!
We appreciate your feedback on our documentation. Let us know how we can improve it.
Submitting feedback through Jira (account required)
- Log in to the Jira website.
- Click Create in the top navigation bar.
- Enter a descriptive title in the Summary field.
- Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
- Click Create at the bottom of the dialogue.
Chapter 1. Vaults in IdM Copier lienLien copié sur presse-papiers!
Learn more about vaults in Identity Management (IdM).
1.1. Vaults and their benefits Copier lienLien copié sur presse-papiers!
You can use an Identity Management (IdM) vault to keep all your sensitive data stored securely but conveniently in one place.
A vault is a secure location in IdM for storing, retrieving, sharing, and recovering a secret. A secret is security-sensitive data, usually authentication credentials, that only a limited group of people or entities can access. For example, secrets include:
- Passwords
- PINs
- Private SSH keys
A vault is comparable to a password manager. Just like a password manager, a vault typically requires a user to generate and remember one primary password to unlock and access any information stored in the vault. However, a user can also decide to have a standard vault. A standard vault does not require the user to enter any password to access the secrets stored in the vault.
The purpose of vaults in IdM is to store authentication credentials that allow you to authenticate to external, non-IdM-related services.
IdM vaults are characterized by the following:
- Vaults are only accessible to the vault owner and those IdM users that the vault owner selects to be the vault members. In addition, the IdM administrator has access to all vaults.
- If a user does not have sufficient privileges to create a vault, an IdM administrator can create the vault and set the user as its owner.
- Users and services can access the secrets stored in a vault from any machine enrolled in the IdM domain.
- One vault can only contain one secret, for example, one file. However, the file itself can contain multiple secrets such as passwords, keytabs or certificates.
Vault is only available from the IdM command line (CLI), not from the IdM Web UI.
1.2. Vault owners, members, and administrators Copier lienLien copié sur presse-papiers!
Identity Management (IdM) distinguishes the following vault user types:
- Vault owner
A vault owner is a user or service with basic management privileges on the vault. For example, a vault owner can modify the properties of the vault or add new vault members.
Each vault must have at least one owner. A vault can also have multiple owners.
- Vault member
- A vault member is a user or service that can access a vault created by another user or service.
- Vault administrator
Vault administrators have unrestricted access to all vaults and are allowed to perform all vault operations. In the context of IdM role-based access control (RBAC), a vault administrator is any IdM user with the
Vault Administratorsprivilege.NoteSymmetric and asymmetric vaults are protected with a password or key. Special access control rules apply for an administrator to:
- Access secrets in symmetric and asymmetric vaults.
- Change or reset the vault password or key.
- Vault User
The vault user represents the user in whose container the vault is located. The
Vault userinformation is displayed in the output of specific commands, such asipa vault-show:ipa vault-show my_vault
$ ipa vault-show my_vault Vault name: my_vault Type: standard Owner users: user Vault user: userCopy to Clipboard Copied! Toggle word wrap Toggle overflow For details on vault containers and user vaults, see Vault containers.
1.3. Standard, symmetric, and asymmetric vaults Copier lienLien copié sur presse-papiers!
Based on the level of security and access control, IdM classifies vaults into the following types:
- Standard vaults
- Vault owners and vault members can archive and retrieve the secret inside a vault without having to use a password or key.
- Symmetric vaults
- Secrets in the vault are protected with a symmetric key. Vault owners and members can archive and retrieve the secrets, but they must provide the vault password.
- Asymmetric vaults
- Secrets in the vault are protected with asymmetric keys. Users archive the secret by using a public key and retrieve it by using a private key. Vault owners can both archive and retrieve secrets. Vault members can only archive secrets.
1.5. Vault containers Copier lienLien copié sur presse-papiers!
A vault container is a collection of vaults. The table below lists the default vault containers that Identity Management (IdM) provides.
| Type | Description | Purpose |
|---|---|---|
| User container | A private container for a user | Stores user vaults for a particular user |
| Service container | A private container for a service | Stores service vaults for a particular service |
| Shared container | A container for multiple users and services | Stores vaults that can be shared by multiple users or services |
IdM creates user and service containers for each user or service automatically when the first private vault for the user or service is created. After the user or service is deleted, IdM removes the container and its contents.
1.6. Basic IdM vault commands Copier lienLien copié sur presse-papiers!
You can use the basic commands outlined below to manage Identity Management (IdM) vaults. The table below contains a list of ipa vault-* commands with the explanation of their purpose.
Before running any ipa vault-* command, install the Key Recovery Authority (KRA) certificate system component on one or more of the servers in your IdM domain. For details, see Installing the Key Recovery Authority in IdM.
| Command | Purpose |
|---|---|
|
| Displays conceptual information about IdM vaults and sample vault commands. |
|
|
Adding the |
|
| When accessing a user vault as a vault member, you must specify the vault owner. If you do not specify the vault owner, IdM informs you that it did not find the vault: ipa vault-show user_vault
|
|
| When accessing a shared vault, you must specify that the vault you want to access is a shared vault. Otherwise, IdM informs you it did not find the vault: ipa vault-show shared_vault
|
1.7. Installing the Key Recovery Authority in IdM Copier lienLien copié sur presse-papiers!
Follow this procedure to enable vaults in Identity Management (IdM) by installing the Key Recovery Authority (KRA) Certificate System (CS) component on a specific IdM server.
Prerequisites
-
You are logged in as
rooton the IdM server. - An IdM certificate authority is installed on the IdM server.
-
You have the
Directory Managercredentials.
Procedure
Install the KRA:
ipa-kra-install
# ipa-kra-installCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To make the vault service highly available and resilient, install the KRA on two IdM servers or more. Maintaining multiple KRA servers prevents data loss.
You can install the first KRA of an IdM cluster on a hidden replica. However, installing additional KRAs requires temporarily activating the hidden replica before you install the KRA clone on a non-hidden replica. Then you can hide the originally hidden replica again.
Chapter 2. Using IdM user vaults: storing and retrieving secrets Copier lienLien copié sur presse-papiers!
This chapter describes how to use user vaults in Identity Management. Specifically, it describes how a user can store a secret in an IdM vault, and how the user can retrieve it. The user can do the storing and the retrieving from two different IdM clients.
Prerequisites
- The Key Recovery Authority (KRA) Certificate System component has been installed on one or more of the servers in your IdM domain. For details, see Installing the Key Recovery Authority in IdM.
2.1. Storing a secret in a user vault Copier lienLien copié sur presse-papiers!
Follow this procedure to create a vault container with one or more private vaults to securely store files with sensitive information. In the example used in the procedure below, the idm_user user creates a vault of the standard type. The standard vault type ensures that idm_user will not be required to authenticate when accessing the file. idm_user will be able to retrieve the file from any IdM client to which the user is logged in.
In the procedure:
- idm_user is the user who wants to create the vault.
- my_vault is the vault used to store the user’s certificate.
-
The vault type is
standard, so that accessing the archived certificate does not require the user to provide a vault password. - secret.txt is the file containing the certificate that the user wants to store in the vault.
Prerequisites
- You know the password of idm_user.
- You are logged in to a host that is an IdM client.
Procedure
Obtain the Kerberos ticket granting ticket (TGT) for
idm_user:kinit idm_user
$ kinit idm_userCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
ipa vault-addcommand with the--type standardoption to create a standard vault:Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantMake sure the first user vault for a user is created by the same user. Creating the first vault for a user also creates the user’s vault container. The agent of the creation becomes the owner of the vault container.
For example, if another user, such as
admin, creates the first user vault foruser1, the owner of the user’s vault container will also beadmin, anduser1will be unable to access the user vault or create new user vaults.Use the
ipa vault-archivecommand with the--inoption to archive thesecret.txtfile into the vault:ipa vault-archive my_vault --in secret.txt
$ ipa vault-archive my_vault --in secret.txt ----------------------------------- Archived data into vault "my_vault" -----------------------------------Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Retrieving a secret from a user vault Copier lienLien copié sur presse-papiers!
As an Identity Management (IdM), you can retrieve a secret from your user private vault onto any IdM client to which you are logged in.
Follow this procedure to retrieve, as an IdM user named idm_user, a secret from the user private vault named my_vault onto idm_client.idm.example.com.
Prerequisites
- idm_user is the owner of my_vault.
- idm_user has archived a secret in the vault.
- my_vault is a standard vault, which means that idm_user does not have to enter any password to access the contents of the vault.
Procedure
SSH to idm_client as idm_user:
ssh idm_user@idm_client.idm.example.com
$ ssh idm_user@idm_client.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Log in as
idm_user:kinit user
$ kinit userCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
ipa vault-retrievecommand with the--outoption to retrieve the contents of the vault and save them into thesecret_exported.txtfile.ipa vault-retrieve my_vault --out secret_exported.txt
$ ipa vault-retrieve my_vault --out secret_exported.txt -------------------------------------- Retrieved data from vault "my_vault" --------------------------------------Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 3. Using Ansible to manage IdM user vaults: storing and retrieving secrets Copier lienLien copié sur presse-papiers!
This chapter describes how to manage user vaults in Identity Management using the Ansible vault module. Specifically, it describes how a user can use Ansible playbooks to perform the following three consecutive actions:
The user can do the storing and the retrieving from two different IdM clients.
Prerequisites
- The Key Recovery Authority (KRA) Certificate System component has been installed on one or more of the servers in your IdM domain. For details, see Installing the Key Recovery Authority in IdM.
3.1. Ensuring the presence of a standard user vault in IdM using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to create a vault container with one or more private vaults to securely store sensitive information. In the example used in the procedure below, the idm_user user creates a vault of the standard type named my_vault. The standard vault type ensures that idm_user will not be required to authenticate when accessing the file. idm_user will be able to retrieve the file from any IdM client to which the user is logged in.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You know the password of idm_user.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/ensure-standard-vault-is-present.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/ensure-standard-vault-is-present.yml ensure-standard-vault-is-present-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/ensure-standard-vault-is-present.yml ensure-standard-vault-is-present-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the ensure-standard-vault-is-present-copy.yml file for editing.
Adapt the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_principalvariable to idm_user. -
Set the
ipaadmin_passwordvariable to the password of idm_user. -
Set the
uservariable to idm_user. -
Set the
namevariable to my_vault. Set the
vault_typevariable to standard.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook -v -i inventory.file ensure-standard-vault-is-present-copy.yml
$ ansible-playbook -v -i inventory.file ensure-standard-vault-is-present-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.2. Archiving a secret in a standard user vault in IdM using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to store sensitive information in a personal vault. In the example used, the idm_user user archives a file with sensitive information named password.txt in a vault named my_vault.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You know the password of idm_user.
- idm_user is the owner, or at least a member user of my_vault.
- You have access to password.txt, the secret that you want to archive in my_vault.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-symmetric-vault.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-symmetric-vault.yml data-archive-in-symmetric-vault-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-symmetric-vault.yml data-archive-in-symmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the data-archive-in-standard-vault-copy.yml file for editing.
Adapt the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_principalvariable to idm_user. -
Set the
ipaadmin_passwordvariable to the password of idm_user. -
Set the
uservariable to idm_user. -
Set the
namevariable to my_vault. -
Set the
invariable to the full path to the file with sensitive information. Set the
actionvariable to member.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook -v -i inventory.file data-archive-in-standard-vault-copy.yml
$ ansible-playbook -v -i inventory.file data-archive-in-standard-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.3. Retrieving a secret from a standard user vault in IdM using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to retrieve a secret from the user personal vault. In the example used in the procedure below, the idm_user user retrieves a file with sensitive data from a vault of the standard type named my_vault onto an IdM client named host01. idm_user does not have to authenticate when accessing the file. idm_user can use Ansible to retrieve the file from any IdM client on which Ansible is installed.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You know the password of idm_user.
- idm_user is the owner of my_vault.
- idm_user has stored a secret in my_vault.
- Ansible can write into the directory on the IdM host into which you want to retrieve the secret.
- idm_user can read from the directory on the IdM host into which you want to retrieve the secret.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-symmetric-vault.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/retrive-data-symmetric-vault.yml retrieve-data-symmetric-vault-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/retrive-data-symmetric-vault.yml retrieve-data-symmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open your inventory file and mention, in a clearly defined section, the IdM client onto which you want to retrieve the secret. For example, to instruct Ansible to retrieve the secret onto host01.idm.example.com, enter:
[ipahost] host01.idm.example.com
[ipahost] host01.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the retrieve-data-standard-vault.yml-copy.yml file for editing.
-
Adapt the file by setting the
hostsvariable to ipahost. Adapt the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_principalvariable to idm_user. -
Set the
ipaadmin_passwordvariable to the password of idm_user. -
Set the
uservariable to idm_user. -
Set the
namevariable to my_vault. -
Set the
outvariable to the full path of the file into which you want to export the secret. Set the
statevariable to retrieved.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook -v -i inventory.file retrieve-data-standard-vault.yml-copy.yml
$ ansible-playbook -v -i inventory.file retrieve-data-standard-vault.yml-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
SSHto host01 as user01:ssh user01@host01.idm.example.com
$ ssh user01@host01.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow View the file specified by the
outvariable in the Ansible playbook file:vim /tmp/password_exported.txt
$ vim /tmp/password_exported.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow
You can now see the exported secret.
Additional resources
-
For more information about using Ansible to manage IdM vaults and user secrets and about playbook variables, see the README-vault.md Markdown file available in the
/usr/share/doc/ansible-freeipa/directory and the sample playbooks available in the/usr/share/doc/ansible-freeipa/playbooks/vault/directory.
Chapter 4. Managing IdM service secrets: storing and retrieving secrets Copier lienLien copié sur presse-papiers!
This section describes how an administrator can use a service vault in Identity Management (IdM) to securely store a service secret in a centralized location. The vault used in the example is asymmetric, which means that to use it, the administrator needs to perform the following steps:
-
Generate a private key using, for example, the
opensslutility. - Generate a public key based on the private key.
The service secret is encrypted with the public key when an administrator archives it into the vault. Afterwards, a service instance hosted on a specific machine in the domain retrieves the secret using the private key. Only the service and the administrator are allowed to access the secret.
If the secret is compromised, the administrator can replace it in the service vault and then redistribute it to those individual service instances that have not been compromised.
Prerequisites
- The Key Recovery Authority (KRA) Certificate System component has been installed on one or more of the servers in your IdM domain. For details, see Installing the Key Recovery Authority in IdM.
In the procedures below:
- The IdM admin user is the administrator who manages the service password.
- private-key-to-an-externally-signed-certificate.pem is the file containing the service secret, in this case a private key to an externally signed certificate. Do not confuse this private key with the private key used to retrieve the secret from the vault.
- secret_vault is the vault created for the service.
- HTTP/webserver.idm.example.com is the service whose secret is being archived.
- service-public.pem is the service public key used to encrypt the password stored in password_vault.
- service-private.pem is the service private key used to decrypt the password stored in secret_vault.
4.1. Storing an IdM service secret in an asymmetric vault Copier lienLien copié sur presse-papiers!
Follow this procedure to create an asymmetric vault and use it to archive a service secret.
Prerequisites
- You know the IdM administrator password.
Procedure
Log in as the administrator:
kinit admin
$ kinit adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the public key of the service instance. For example, using the
opensslutility:Generate the
service-private.pemprivate key.openssl genrsa -out service-private.pem 2048
$ openssl genrsa -out service-private.pem 2048 Generating RSA private key, 2048 bit long modulus .+++ ...........................................+++ e is 65537 (0x10001)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the
service-public.pempublic key based on the private key.openssl rsa -in service-private.pem -out service-public.pem -pubout
$ openssl rsa -in service-private.pem -out service-public.pem -pubout writing RSA keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create an asymmetric vault as the service instance vault, and provide the public key:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The password archived into the vault will be protected with the key.
Archive the service secret into the service vault:
ipa vault-archive secret_vault --service HTTP/webserver.idm.example.com --in private-key-to-an-externally-signed-certificate.pem
$ ipa vault-archive secret_vault --service HTTP/webserver.idm.example.com --in private-key-to-an-externally-signed-certificate.pem ----------------------------------- Archived data into vault "secret_vault" -----------------------------------Copy to Clipboard Copied! Toggle word wrap Toggle overflow This encrypts the secret with the service instance public key.
Repeat these steps for every service instance that requires the secret. Create a new asymmetric vault for each service instance.
4.2. Retrieving a service secret for an IdM service instance Copier lienLien copié sur presse-papiers!
Follow this procedure to use a service instance to retrieve the service vault secret using a locally-stored service private key.
Prerequisites
- You have access to the keytab of the service principal owning the service vault, for example HTTP/webserver.idm.example.com.
- You have created an asymmetric vault and archived a secret in the vault.
- You have access to the private key used to retrieve the service vault secret.
Procedure
Log in as the administrator:
kinit admin
$ kinit adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain a Kerberos ticket for the service:
kinit HTTP/webserver.idm.example.com -k -t /etc/httpd/conf/ipa.keytab
# kinit HTTP/webserver.idm.example.com -k -t /etc/httpd/conf/ipa.keytabCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the service vault password:
ipa vault-retrieve secret_vault --service HTTP/webserver.idm.example.com --private-key-file service-private.pem --out secret.txt
$ ipa vault-retrieve secret_vault --service HTTP/webserver.idm.example.com --private-key-file service-private.pem --out secret.txt ------------------------------------ Retrieved data from vault "secret_vault" ------------------------------------Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.3. Changing an IdM service vault secret when compromised Copier lienLien copié sur presse-papiers!
Follow this procedure to isolate a compromised service instance by changing the service vault secret.
Prerequisites
- You know the IdM administrator password.
- You have created an asymmetric vault to store the service secret.
- You have generated the new secret and have access to it, for example in the new-private-key-to-an-externally-signed-certificate.pem file.
Procedure
Archive the new secret into the service instance vault:
ipa vault-archive secret_vault --service HTTP/webserver.idm.example.com --in new-private-key-to-an-externally-signed-certificate.pem
$ ipa vault-archive secret_vault --service HTTP/webserver.idm.example.com --in new-private-key-to-an-externally-signed-certificate.pem ----------------------------------- Archived data into vault "secret_vault" -----------------------------------Copy to Clipboard Copied! Toggle word wrap Toggle overflow This overwrites the current secret stored in the vault.
- Retrieve the new secret on non-compromised service instances only. For details, see Retrieving a service secret for an IdM service instance.
Chapter 5. Using Ansible to manage IdM service vaults: storing and retrieving secrets Copier lienLien copié sur presse-papiers!
This section describes how an administrator can use the ansible-freeipa vault module to securely store a service secret in a centralized location. The vault used in the example is asymmetric, which means that to use it, the administrator needs to perform the following steps:
-
Generate a private key using, for example, the
opensslutility. - Generate a public key based on the private key.
The service secret is encrypted with the public key when an administrator archives it into the vault. Afterwards, a service instance hosted on a specific machine in the domain retrieves the secret using the private key. Only the service and the administrator are allowed to access the secret.
If the secret is compromised, the administrator can replace it in the service vault and then redistribute it to those individual service instances that have not been compromised.
Prerequisites
- All the IdM servers in the ipaserver host category defined in the playbooks below have the Key Recovery Authority (KRA) Certificate System component installed on them. For details, see Installing the Key Recovery Authority in IdM.
In the procedures:
- The IdM admin user is the administrator who manages the service password.
- private-key-to-an-externally-signed-certificate.pem is the file containing the service secret, in this case a private key to an externally signed certificate. Do not confuse this private key with the private key used to retrieve the secret from the vault.
- secret_vault is the vault created to store the service secret.
- HTTP/webserver1.idm.example.com is the service that is the owner of the vault.
- HTTP/webserver2.idm.example.com and HTTP/webserver3.idm.example.com are the vault member services.
- service-public.pem is the service public key used to encrypt the password stored in password_vault.
- service-private.pem is the service private key used to decrypt the password stored in secret_vault.
5.1. Ensuring the presence of an asymmetric service vault in IdM using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to create a service vault container with one or more private vaults to securely store sensitive information. In the example used in the procedure below, the administrator creates an asymmetric vault named secret_vault. This ensures that the vault members have to authenticate using a private key to retrieve the secret in the vault. The vault members will be able to retrieve the file from any IdM client.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/ensure-asymmetric-vault-is-present.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/ensure-asymmetric-vault-is-present.yml ensure-asymmetric-vault-is-present-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/ensure-asymmetric-vault-is-present.yml ensure-asymmetric-vault-is-present-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the public key of the service instance. For example, using the
opensslutility:Generate the
service-private.pemprivate key.openssl genrsa -out service-private.pem 2048
$ openssl genrsa -out service-private.pem 2048 Generating RSA private key, 2048 bit long modulus .+++ ...........................................+++ e is 65537 (0x10001)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the
service-public.pempublic key based on the private key.openssl rsa -in service-private.pem -out service-public.pem -pubout
$ openssl rsa -in service-private.pem -out service-public.pem -pubout writing RSA keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- Open the ensure-asymmetric-vault-is-present-copy.yml file for editing.
- Add a task that copies the service-public.pem public key from the Ansible controller to the server.idm.example.com server.
Modify the rest of the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_passwordvariable to the IdM administrator password. -
Define the name of the vault using the
namevariable, for example secret_vault. -
Set the
vault_typevariable to asymmetric. -
Set the
servicevariable to the principal of the service that owns the vault, for example HTTP/webserver1.idm.example.com. Set the
public_key_fileto the location of your public key.This is the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file ensure-asymmetric-service-vault-is-present-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file ensure-asymmetric-service-vault-is-present-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.2. Adding member services to an asymmetric vault using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to add member services to a service vault so that they can all retrieve the secret stored in the vault. In the example used in the procedure below, the IdM administrator adds the HTTP/webserver2.idm.example.com and HTTP/webserver3.idm.example.com service principals to the secret_vault vault that is owned by HTTP/webserver1.idm.example.com.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You have created an asymmetric vault to store the service secret.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-asymmetric-vault.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-asymmetric-vault.yml data-archive-in-asymmetric-vault-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-asymmetric-vault.yml data-archive-in-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the data-archive-in-asymmetric-vault-copy.yml file for editing.
Modify the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_passwordvariable to the IdM administrator password. -
Set the
namevariable to the name of the vault, for example secret_vault. -
Set the
servicevariable to the service owner of the vault, for example HTTP/webserver1.idm.example.com. -
Define the services that you want to have access to the vault secret using the
servicesvariable. Set the
actionvariable tomember.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file add-services-to-an-asymmetric-vault.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file add-services-to-an-asymmetric-vault.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.3. Storing an IdM service secret in an asymmetric vault using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to store a secret in a service vault so that it can be later retrieved by the service. In the example used in the procedure below, the administrator stores a PEM file with the secret in an asymmetric vault named secret_vault. This ensures that the service will have to authenticate using a private key to retrieve the secret from the vault. The service will be able to retrieve the file from any IdM client.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You have created an asymmetric vault to store the service secret.
- The secret is stored locally on the Ansible controller, for example in the /usr/share/doc/ansible-freeipa/playbooks/vault/private-key-to-an-externally-signed-certificate.pem file.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-asymmetric-vault.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-asymmetric-vault.yml data-archive-in-asymmetric-vault-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/data-archive-in-asymmetric-vault.yml data-archive-in-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the data-archive-in-asymmetric-vault-copy.yml file for editing.
Modify the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_passwordvariable to the IdM administrator password. -
Set the
namevariable to the name of the vault, for example secret_vault. -
Set the
servicevariable to the service owner of the vault, for example HTTP/webserver1.idm.example.com. -
Set the
invariable to "{{ lookup('file', 'private-key-to-an-externally-signed-certificate.pem') | b64encode }}". This ensures that Ansible retrieves the file with the private key from the working directory on the Ansible controller rather than from the IdM server. Set the
actionvariable tomember.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file data-archive-in-asymmetric-vault-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file data-archive-in-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Retrieving a service secret for an IdM service using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to use an Ansible playbook to retrieve a secret from a service vault on behalf of the service. In the example used in the procedure below, running the playbook retrieves a PEM file with the secret from an asymmetric vault named secret_vault, and stores it in the specified location on all the hosts listed in the Ansible inventory file as ipaservers.
The services authenticate to IdM using keytabs, and they authenticate to the vault using a private key. You can retrieve the file on behalf of the service from any IdM client on which ansible-freeipa is installed.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You have created an asymmetric vault to store the service secret.
- You have archived the secret in the vault.
-
You have stored the private key used to retrieve the service vault secret in the location specified by the
private_key_filevariable on the Ansible controller.
Procedure
Navigate to the MyPlaybooks directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Make a copy of the /usr/share/doc/ansible-freeipa/playbooks/vault/retrieve-data-asymmetric-vault.yml Ansible playbook file. For example:
cp /usr/share/doc/ansible-freeipa/playbooks/vault/retrieve-data-asymmetric-vault.yml retrieve-data-asymmetric-vault-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/vault/retrieve-data-asymmetric-vault.yml retrieve-data-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open your inventory file and define the following hosts:
-
Define your IdM server in the
[ipaserver]section. -
Define the hosts onto which you want to retrieve the secret in the
[webservers]section. For example, to instruct Ansible to retrieve the secret to webserver1.idm.example.com, webserver2.idm.example.com, and webserver3.idm.example.com, enter:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Define your IdM server in the
- Open the retrieve-data-asymmetric-vault-copy.yml file for editing.
Modify the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_passwordvariable to your IdM administrator password. -
Set the
namevariable to the name of the vault, for example secret_vault. -
Set the
servicevariable to the service owner of the vault, for example HTTP/webserver1.idm.example.com. -
Set the
private_key_filevariable to the location of the private key used to retrieve the service vault secret. -
Set the
outvariable to the location on the IdM server where you want to retrieve the private-key-to-an-externally-signed-certificate.pem secret, for example the current working directory. Set the
actionvariable tomember.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Add a section to the playbook that retrieves the data file from the IdM server to the Ansible controller:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a section to the playbook that transfers the retrieved private-key-to-an-externally-signed-certificate.pem file from the Ansible controller on to the webservers listed in the
webserverssection of the inventory file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file retrieve-data-asymmetric-vault-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file retrieve-data-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5. Changing an IdM service vault secret when compromised using Ansible Copier lienLien copié sur presse-papiers!
Follow this procedure to reuse an Ansible playbook to change the secret stored in a service vault when a service instance has been compromised. The scenario in the following example assumes that on webserver3.idm.example.com, the retrieved secret has been compromised, but not the key to the asymmetric vault storing the secret. In the example, the administrator reuses the Ansible playbooks used when storing a secret in an asymmetric vault and retrieving a secret from the asymmetric vault onto IdM hosts. At the start of the procedure, the IdM administrator stores a new PEM file with a new secret in the asymmetric vault, adapts the inventory file so as not to retrieve the new secret on to the compromised web server, webserver3.idm.example.com, and then re-runs the two procedures.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password.
-
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica. - You know the IdM administrator password.
- You have created an asymmetric vault to store the service secret.
-
You have generated a new
httpdkey for the web services running on IdM hosts to replace the compromised old key. -
The new
httpdkey is stored locally on the Ansible controller, for example in the /usr/share/doc/ansible-freeipa/playbooks/vault/private-key-to-an-externally-signed-certificate.pem file.
Procedure
Navigate to the
/usr/share/doc/ansible-freeipa/playbooks/vaultdirectory:cd /usr/share/doc/ansible-freeipa/playbooks/vault
$ cd /usr/share/doc/ansible-freeipa/playbooks/vaultCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open your inventory file and make sure that the following hosts are defined correctly:
-
The IdM server in the
[ipaserver]section. The hosts onto which you want to retrieve the secret in the
[webservers]section. For example, to instruct Ansible to retrieve the secret to webserver1.idm.example.com and webserver2.idm.example.com, enter:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
ImportantMake sure that the list does not contain the compromised webserver, in the current example webserver3.idm.example.com.
-
The IdM server in the
Make a copy of the data-archive-in-asymmetric-vault.yml Ansible playbook file, for example:
cp data-archive-in-asymmetric-vault.yml data-archive-in-asymmetric-vault-copy.yml
$ cp data-archive-in-asymmetric-vault.yml data-archive-in-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the data-archive-in-asymmetric-vault-copy.yml file for editing.
Modify the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_passwordvariable to the IdM administrator password. -
Set the
namevariable to the name of the vault, for example secret_vault. -
Set the
servicevariable to the service owner of the vault, for example HTTP/webserver.idm.example.com. -
Set the
invariable to "{{ lookup('file', 'new-private-key-to-an-externally-signed-certificate.pem') | b64encode }}". This ensures that Ansible retrieves the file with the private key from the working directory on the Ansible controller rather than from the IdM server. Set the
actionvariable tomember.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
- Save the file.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file data-archive-in-asymmetric-vault-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file data-archive-in-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the retrieve-data-asymmetric-vault-copy.yml file for editing.
Modify the file by setting the following variables in the
ipavaulttask section:-
Set the
ipaadmin_passwordvariable to your IdM administrator password. -
Set the
namevariable to the name of the vault, for example secret_vault. -
Set the
servicevariable to the service owner of the vault, for example HTTP/webserver1.idm.example.com. -
Set the
private_key_filevariable to the location of the private key used to retrieve the service vault secret. -
Set the
outvariable to the location on the IdM server where you want to retrieve the new-private-key-to-an-externally-signed-certificate.pem secret, for example the current working directory. Set the
actionvariable tomember.This the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Add a section to the playbook that retrieves the data file from the IdM server to the Ansible controller:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add a section to the playbook that transfers the retrieved new-private-key-to-an-externally-signed-certificate.pem file from the Ansible controller on to the webservers listed in the
webserverssection of the inventory file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i inventory.file retrieve-data-asymmetric-vault-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory.file retrieve-data-asymmetric-vault-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow