

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 创建 ONTAP 用户
<a name="create-new-ontap-users"></a>

**创建新的 SVM 或文件系统用户（ONTAP CLI）**

只有具有 `fsxadmin` 角色的文件系统用户才能创建新的 SVM 和文件系统用户。

1. 要访问 ONTAP CLI，请运行以下命令在 Amazon FSx for NetApp ONTAP 文件系统或 SVM 的管理端口上建立 SSH 会话。将 `management_endpoint_ip` 替换为文件系统管理端口的 IP 地址。

   ```
   [~]$ ssh fsxadmin@management_endpoint_ip
   ```

   有关更多信息，请参阅 [使用 ONTAP CLI 管理文件系统](managing-resources-ontap-apps.md#fsxadmin-ontap-cli)。

1. 使用 `security login create` ONTAP CLI 命令在您 FSx 的 ONTAP 文件系统或 SVM 上创建一个新的用户帐户。

   为示例中的占位符填入数据，以定义以下必需的属性：
   + `-vserver` – 指定要在其中创建新 SVM 角色或用户的 SVM 的名称。如果要创建文件系统角色或用户，请不要指定 SVM。
   + `-user-or-group-name` – 指定登录方法的用户名或 Active Directory 组名。只能使用 `domain` 身份验证方法以及 `ontapi` 和 `ssh` 应用程序指定 Active Directory 组名。
   + `-application` – 指定登录方法的应用。可能的值包括 http、ontapi 和 ssh。
   + `-authentication-method` – 指定登录的身份验证方法。可能的值包括：
     + domain – 用于 Active Directory 身份验证
     + 密码 - 用于密码认证
     + publickey – 用于公钥身份验证
   + `-role` – 指定登录方法的访问控制角色名称。在文件系统级别，唯一可以指定的角色是 `fsxadmin`。

   （可选）您还可以将以下一个或多个参数与命令配合使用：
   + `[-comment]` - 用于为用户账户添加注释或备注。例如 **Guest account**。最大长度为 128 个字符。
   + `[-second-authentication-method {none|publickey|password|nsswitch}]` – 指定第二种身份验证方法。您可以指定以下方法：
     + 密码 - 用于密码认证
     + publickey – 用于公钥身份验证
     + nswitch – 用于 NIS 或 LDAP 身份验证
     + 无 - 未指定时的默认值。

   ```
   Fsx0123456::> security login create -vserver vserver_name -user-or-group-name user_or_group_name -application login_application -authentication-method auth_method -role role_or_account_name
   ```

   以下命令结合使用 SSH 和登录密码创建具有 `fsxadmin-readonly` 角色的新文件系统用户 `new_fsxadmin`。在提示时，提供此用户的密码。

   ```
   Fsx0123456::> security login create -user-or-group-name new_fsxadmin -application ssh -authentication-method password -role fsxadmin-readonly
   
   Please enter a password for user 'new_fsxadmin':
   Please enter it again: 
   
   Fsx0123456::>
   ```

1. 以下命令在 SVM `fsx` 上创建具有 `vsadmin_readonly` 角色的新 SVM 用户 `new_vsadmin`，配置为将 SSH 和登录密码配合使用。在提示时，提供此用户的密码。

   ```
   Fsx0123456::> security login create -vserver fsx  -user-or-group-name new_vsadmin -application ssh -authentication-method password -role vsadmin-readonly
   
   Please enter a password for user 'new_vsadmin': 
   Please enter it again:
   
   Fsx0123456::>
   ```

1. 以下命令创建一个新的只读文件系统用户`harvest2-user`， NetApp Harvest 应用程序将使用该用户来收集性能和容量指标。有关更多信息，请参阅 [使用 Harvest 和 Grafana 监控 FSx for ONTAP 文件系统](monitoring-harvest-grafana.md)。

   ```
   Fsx0123456::> security login create -user-or-group-name harvest2-user -application ssh -role fsxadmin-readonly -authentication-method password
   ```

**查看所有文件系统和 SVM 用户的信息**
+ 使用以下命令查看文件系统和的所有登录信息 SVMs。

  ```
  Fsx0123456::> security login show
  
  Vserver: Fsx0123456
                                                                   Second
  User/Group                 Authentication                 Acct   Authentication
  Name           Application Method        Role Name        Locked Method
  -------------- ----------- ------------- ---------------- ------ --------------
  autosupport    console     password      autosupport      no     none
  fsxadmin       http        password      fsxadmin         no     none
  fsxadmin       ontapi      password      fsxadmin         no     none
  fsxadmin       ssh         password      fsxadmin         no     none
  fsxadmin       ssh         publickey     fsxadmin         -      none
  new_fsxadmin   ssh         password      fsxadmin-readonly 
                                                            no     none
  
  Vserver: fsx
                                                                   Second
  User/Group                 Authentication                 Acct   Authentication
  Name           Application Method        Role Name        Locked Method
  -------------- ----------- ------------- ---------------- ------ --------------
  new_vsadmin    ssh         password      vsadmin-readonly no     none
  vsadmin        http        password      vsadmin          yes    none
  vsadmin        ontapi      password      vsadmin          yes    none
  vsadmin        ssh         password      vsadmin          yes    none
  10 entries were displayed.
  
  Fsx0123456::>
  ```