|
| 1 | +--- |
| 2 | +title: Synchronize users and keys across Azure Cloud HSM nodes |
| 3 | +description: Learn how to identify and fix missing users or keys across Azure Cloud HSM cluster nodes. |
| 4 | +author: keithp |
| 5 | +manager: davinune |
| 6 | +ms.service: azure-cloud-hsm |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 03/20/2025 |
| 9 | +ms.author: keithp |
| 10 | +--- |
| 11 | + |
| 12 | +# Synchronize users and keys across Azure Cloud HSM nodes |
| 13 | + |
| 14 | +This article explains how to identify and resolve synchronization issues when users or keys are missing from one or more nodes in your Azure Cloud HSM cluster. |
| 15 | + |
| 16 | +## Overview |
| 17 | + |
| 18 | +In some cases, users or keys might not be replicated to all nodes in your Azure Cloud HSM cluster. This can occur during service events such as self-healing or upgrades, or if creation fails on one or more nodes. If you're experiencing intermittent authentication failures or cryptographic operation errors, you might have users or keys that need to be synchronized. |
| 19 | + |
| 20 | +> [!IMPORTANT] |
| 21 | +> A user or key that exists on only one node is at risk of permanent, unrecoverable loss if that node fails. If you identify missing users or keys, synchronize them immediately and ensure you have current backups. |
| 22 | +
|
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +- Access to a VM with the Azure Cloud HSM SDK installed |
| 26 | +- The `azcloudhsm_mgmt_util` tool |
| 27 | +- Cryptography officer (CO) credentials for your Azure Cloud HSM deployment |
| 28 | + |
| 29 | +## User synchronization |
| 30 | + |
| 31 | +All users in Azure Cloud HSM are fully managed by the customer. The service doesn't perform backend user synchronization if user creation fails. If user creation fails on one or more nodes, you must manually synchronize the user to the missing nodes. |
| 32 | + |
| 33 | +> [!IMPORTANT] |
| 34 | +> Ensure that all users are consistently created and present across every node in the cluster. If a user is missing or creation fails on any node, you must execute the required commands and perform validation steps to restore consistency. |
| 35 | +
|
| 36 | +### Identify missing users |
| 37 | + |
| 38 | +1. Start the management utility: |
| 39 | + |
| 40 | + ```bash |
| 41 | + ./azcloudhsm_mgmt_util ./azcloudhsm_resource.cfg |
| 42 | + ``` |
| 43 | + |
| 44 | +1. Run the `listUsers` command to display the User ID, User Type, and Username under each node (server 0, 1, 2): |
| 45 | + |
| 46 | + ```bash |
| 47 | + listUsers |
| 48 | + ``` |
| 49 | + |
| 50 | +1. Observe the number of users found for each node and corresponding usernames. Compare the lists across all three servers to identify any missing users. |
| 51 | + |
| 52 | +### Synchronize missing users |
| 53 | + |
| 54 | +1. Sign in as a cryptography officer (CO): |
| 55 | + |
| 56 | + ```bash |
| 57 | + loginHSM CO admin <adminPassword> |
| 58 | + ``` |
| 59 | + |
| 60 | + Verify that you successfully signed in to all three nodes: |
| 61 | + |
| 62 | + ```output |
| 63 | + loginHSM success on server 0 |
| 64 | + loginHSM success on server 1 |
| 65 | + loginHSM success on server 2 |
| 66 | + ``` |
| 67 | + |
| 68 | + > [!NOTE] |
| 69 | + > If sign-in fails on any node, the sync operation might fail. Ensure successful sign-in to all nodes before proceeding. |
| 70 | +
|
| 71 | +1. Identify the source node that has the user. In this example, server 0 has a user that's not available on server 1 and server 2: |
| 72 | + |
| 73 | + ```bash |
| 74 | + server 0 |
| 75 | + ``` |
| 76 | + |
| 77 | +1. Run the `syncUser` command for each server where the user is missing. Replace `<UserID>` with the actual User ID: |
| 78 | + |
| 79 | + ```bash |
| 80 | + syncUser <UserID> 1 |
| 81 | + syncUser <UserID> 2 |
| 82 | + ``` |
| 83 | + |
| 84 | + > [!NOTE] |
| 85 | + > If `syncUser` is executed against a node where the user already exists, the error message "user already created, unable to insert object" appears. If the user doesn't exist, the operation succeeds. |
| 86 | +
|
| 87 | +### Validate user synchronization |
| 88 | + |
| 89 | +1. Exit the current server context: |
| 90 | + |
| 91 | + ```bash |
| 92 | + exit |
| 93 | + ``` |
| 94 | + |
| 95 | +1. Run `listUsers` to confirm that all User IDs, User Types, and Usernames are now equal and available under each node (server 0, 1, 2): |
| 96 | + |
| 97 | + ```bash |
| 98 | + listUsers |
| 99 | + ``` |
| 100 | + |
| 101 | +## Key synchronization |
| 102 | + |
| 103 | +When you create keys, it's your responsibility to ensure keys are present on all nodes. Although Azure Cloud HSM supports service-side key synchronization and restore operations, you must verify that keys are available on any missing nodes before use. |
| 104 | + |
| 105 | +> [!IMPORTANT] |
| 106 | +> If a key is missing or creation fails on any node, you must execute the appropriate commands and perform validation steps to restore consistency. A key that exists on only one node is at risk of permanent loss if that node fails. |
| 107 | +
|
| 108 | +### Identify missing keys |
| 109 | + |
| 110 | +1. Start the management utility: |
| 111 | + |
| 112 | + ```bash |
| 113 | + ./azcloudhsm_mgmt_util ./azcloudhsm_resource.cfg |
| 114 | + ``` |
| 115 | + |
| 116 | +1. Sign in as a cryptography officer (CO): |
| 117 | + |
| 118 | + ```bash |
| 119 | + loginHSM CO admin <adminPassword> |
| 120 | + ``` |
| 121 | + |
| 122 | + Verify that you successfully signed in to all three nodes: |
| 123 | + |
| 124 | + ```output |
| 125 | + loginHSM success on server 0 |
| 126 | + loginHSM success on server 1 |
| 127 | + loginHSM success on server 2 |
| 128 | + ``` |
| 129 | + |
| 130 | +1. Run the `findAllKeys` command to display the number of keys and key handle IDs under each node: |
| 131 | + |
| 132 | + ```bash |
| 133 | + findAllKeys 0 0 |
| 134 | + ``` |
| 135 | + |
| 136 | +1. Observe the number of keys found for each node and corresponding key handle IDs. Compare the results across all three servers to identify any missing keys. |
| 137 | + |
| 138 | +### Synchronize missing keys |
| 139 | + |
| 140 | +1. Identify the source node that has the key. In this example, server 0 has a key handle that's not available on server 1 and server 2: |
| 141 | + |
| 142 | + ```bash |
| 143 | + server 0 |
| 144 | + ``` |
| 145 | + |
| 146 | +1. Run the `syncKey` command for each server where the key is missing. Replace `<KeyHandle>` with the actual key handle ID: |
| 147 | + |
| 148 | + ```bash |
| 149 | + syncKey <KeyHandle> 1 |
| 150 | + syncKey <KeyHandle> 2 |
| 151 | + ``` |
| 152 | + |
| 153 | + For example, to synchronize key handle 262150 to servers 1 and 2: |
| 154 | + |
| 155 | + ```bash |
| 156 | + syncKey 262150 1 |
| 157 | + syncKey 262150 2 |
| 158 | + ``` |
| 159 | + |
| 160 | +### Validate key synchronization |
| 161 | + |
| 162 | +1. Exit the current server context: |
| 163 | + |
| 164 | + ```bash |
| 165 | + exit |
| 166 | + ``` |
| 167 | + |
| 168 | +1. Run `findAllKeys 0 0` to confirm that all key handles and the number of keys found are now equal and available under each node (server 0, 1, 2): |
| 169 | + |
| 170 | + ```bash |
| 171 | + findAllKeys 0 0 |
| 172 | + ``` |
| 173 | + |
| 174 | +## Best practices |
| 175 | + |
| 176 | +To prevent synchronization issues and potential data loss: |
| 177 | + |
| 178 | +- **Verify after creation**: After creating any user or key, immediately verify that it exists on all three nodes. |
| 179 | +- **Maintain regular backups**: Use the [backup and restore](backup-restore.md) functionality to protect against node failures. |
| 180 | +- **Monitor for discrepancies**: Periodically run `listUsers` and `findAllKeys 0 0` to check for inconsistencies across nodes. |
| 181 | +- **Act quickly on failures**: If you notice a user or key creation failure, synchronize it to the missing nodes before a node failure occurs. |
| 182 | + |
| 183 | +## Related content |
| 184 | + |
| 185 | +- [Troubleshoot Azure Cloud HSM](troubleshoot.md) |
| 186 | +- [User management in Azure Cloud HSM](user-management.md) |
| 187 | +- [Key management in Azure Cloud HSM](key-management.md) |
| 188 | +- [Backup and restore in Azure Cloud HSM](backup-restore.md) |
0 commit comments