

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Management AWS CloudHSM Utility (CMU) 入門
<a name="cloudhsm_mgmt_util-getting-started"></a>

AWS CloudHSM Management Utility (CMU) 可讓您管理硬體安全模組 (HSM) 使用者。使用本主題可開始進行基本的 HSM 使用者管理工作，例如建立使用者、列出使用者以及將 CMU 連線到叢集。

1. 若要使用 CMU，您必須先使用設定工具，以 `--cmu` 參數和叢集中其中一個 HSM 的 IP 地址來更新本機 CMU 組態。每次使用 CMU 時，執行此操作，以確保您管理叢集中每個 HSM 上的 HSM 使用者。

------
#### [ Linux ]

   ```
   $ sudo /opt/cloudhsm/bin/configure --cmu {{<IP address>}}
   ```

------
#### [ Windows ]

   ```
   PS C:\> & "C:\Program Files\Amazon\CloudHSM\configure.exe" --cmu {{<IP address>}}
   ```

------

1. 在互動式模式中輸入下列命令啟動 CLI。

------
#### [ Linux ]

   ```
   $ /opt/cloudhsm/bin/cloudhsm_mgmt_util /opt/cloudhsm/etc/cloudhsm_mgmt_util.cfg
   ```

------
#### [ Windows ]

   ```
   PS C:\> & "C:\Program Files\Amazon\CloudHSM\cloudhsm_mgmt_util.exe" C:\ProgramData\Amazon\CloudHSM\data\cloudhsm_mgmt_util.cfg
   ```

------

   輸出應該類似如下，視您有多少個 HSM 而定。

   ```
   Connecting to the server(s), it may take time
   depending on the server(s) load, please wait...
   
   Connecting to server '10.0.2.9': hostname '10.0.2.9', port 2225...
   Connected to server '10.0.2.9': hostname '10.0.2.9', port 2225.
   
   Connecting to server '10.0.3.11': hostname '10.0.3.11', port 2225...
   Connected to server '10.0.3.11': hostname '10.0.3.11', port 2225.
   
   Connecting to server '10.0.1.12': hostname '10.0.1.12', port 2225...
   Connected to server '10.0.1.12': hostname '10.0.1.12', port 2225.
   ```

   cloudhsm\_mgmt\_util 執行時，系統提示會切換至 `aws-cloudhsm>`。

1. 使用 **loginHSM** 命令登入叢集。任何類型的使用者都可以使用此命令來登入叢集。

   以下範例中的命令以 *admin* 登入，這是預設的[加密管理員 (CO)](understanding-users-cmu.md)。您已在啟用叢集時設定此使用者的密碼。您可以使用 `-hpswd` 參數來隱藏您的密碼。

   ```
   aws-cloudhsm>loginHSM CO admin -hpswd
   ```

   系統會提示您輸入密碼。您輸入密碼時，系統會隱藏密碼，並且輸出顯示命令已成功，並顯示您已連線至叢集上的所有 HSM。

   ```
   Enter password:
   
   
   loginHSM success on server 0(10.0.2.9)
   loginHSM success on server 1(10.0.3.11)
   loginHSM success on server 2(10.0.1.12)
   ```

1.  用 **listUsers** 來列出叢集上的所有使用者。

   ```
   aws-cloudhsm>listUsers
   ```

   CMU 列出了叢集上的所有使用者。

   ```
   Users on server 0(10.0.2.9):
   Number of users found:2
   
       User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
            1              CO              admin                                    NO               0               NO
            2              AU              app_user                                 NO               0               NO
   Users on server 1(10.0.3.11):
   Number of users found:2
   
       User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
            1              CO              admin                                    NO               0               NO
            2              AU              app_user                                 NO               0               NO
   Users on server 2(10.0.1.12):
   Number of users found:2
   
       User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
            1              CO              admin                                    NO               0               NO
            2              AU              app_user                                 NO               0               NO
   ```

1.  使用 **createUser** 來建立名為 **example\_user** 的 CU 使用者，密碼為 **password1**。

   您可以在應用程式中使用 CU 使用者來執行密碼編譯和金鑰管理操作。您可以建立 CU 使用者，因為在步驟 3 中您是以 CO 使用者身分登入的。只有 CO 使用者可以使用 CMU 執行使用者管理工作，例如建立和刪除使用者，以及變更其他使用者的密碼。

   ```
   aws-cloudhsm>createUser CU example_user password1
   ```

   CMU 會提示您建立使用者操作。

   ```
   *************************CAUTION********************************
   This is a CRITICAL operation, should be done on all nodes in the
   cluster. AWS does NOT synchronize these changes automatically with the
   nodes on which this operation is not executed or failed, please
   ensure this operation is executed on all nodes in the cluster.
   ****************************************************************
   
   Do you want to continue(y/n)?
   ```

1. 若要建立 CU 使用者 **example\_user**，請輸入 **y**。

1.  用 **listUsers** 來列出叢集上的所有使用者。

   ```
   aws-cloudhsm>listUsers
   ```

   CMU 會列出叢集上的所有使用者，包括您剛建立的新 CU 使用者。

   ```
   Users on server 0(10.0.2.9):
   Number of users found:3
   
       User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
            1              CO              admin                                    NO               0               NO
            2              AU              app_user                                 NO               0               NO
            3              CU              example_user                             NO               0               NO
   Users on server 1(10.0.3.11):
   Number of users found:3
   
       User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
            1              CO              admin                                    NO               0               NO
            2              AU              app_user                                 NO               0               NO
            3              CU              example_user                             NO               0               NO
   Users on server 2(10.0.1.12):
   Number of users found:3
   
       User Id             User Type       User Name                          MofnPubKey    LoginFailureCnt         2FA
            1              CO              admin                                    NO               0               NO
            2              AU              app_user                                 NO               0               NO
            3              CU              example_user                             NO               0               NO
   ```

1. 使用 **logoutHSM** 命令來登出 HSM。

   ```
   aws-cloudhsm>logoutHSM
   
   
   logoutHSM success on server 0(10.0.2.9)
   logoutHSM success on server 1(10.0.3.11)
   logoutHSM success on server 2(10.0.1.12)
   ```

1. 使用 **quit** 命令來停止 cloudhsm\_mgmt\_util。

   ```
   aws-cloudhsm>quit
   
   
   disconnecting from servers, please wait...
   ```