设置 Linux 主机的认证
您可以为 Linux 主机设置单向 CHAP 认证。在配置用于主机的单向认证之后,可以选择设置双向认证。
开始之前
系统支持两种提问握手认证协议 (CHAP) 方法:
- 单向 CHAP 认证(系统认证主机 iSCSI 发起程序)。
- 双向 CHAP 认证(系统和发起程序互相认证)。
注: 您为单向认证和双向认证选择的 CHAP 秘密必须不同。
过程
要设置 Linux 主机的认证,请执行以下步骤:
- 使用适当的编辑器打开 /etc/iscsi/iscsid.conf 或 /etc/iscsid.conf。
- 转至 CHAP 设置段。
以下示例显示了输出:
图 1. Linux 主机的 CHAP 设置#************* #CHAP Settings #************* #To enable CHAP authentication set node.session.auth.authmethod #to CHAP. The default is None. #node.session.auth.authmethod = CHAP #To set a CHAP username and password for initiator #authentication by the target(s), uncomment the following lines: #node.session.auth.username = username #node.session.auth.password = password node.session.auth.username = rhel_username node.session.auth.password = xxxxxxxxxxxxx #To set a CHAP username and password for target(s) #authentication by the initiator, uncomment the following lines: #node.session.auth.username_in = username_in #node.session.auth.password_in = password_in node.session.auth.password_in = yyyyyyyyyyyyy #To enable CHAP authentication for a discovery session to the target #set discovery.sendtargets.auth.authmethod to CHAP. The default is None. #discovery.sendtargets.auth.authmethod = CHAP discovery.sendtargets.auth.authmethod = CHAP #To set a discovery session CHAP username and password for the initiator #authentication by the target(s), uncomment the following lines: #discovery.sendtargets.auth.username = username #discovery.sendtargets.auth.password = password #To set a discovery session CHAP username and password for target(s) #authentication by the initiator, uncomment the following lines: #discovery.sendtargets.auth.username_in = username_in #discovery.sendtargets.auth.password_in = password_in - 设置认证。
- 设置单向认证:
- 设置发起程序名称的 CHAP 用户名和密码。
- node.session.auth.authmethod = CHAP
- node.session.auth.username = <initiator's user name>
- node.session.auth.password = <CHAP secret for host>
- 设置发起程序名称的发现会话 CHAP 用户名和密码。
- discovery.sendtargets.auth.authmethod = CHAP
- discovery.sendtargets.auth.username = <initiator's user name>
- discovery.sendtargets.auth.password = <CHAP secret for host>
- 保存这些设置。您必须注销任何当前会话并重新发现系统 iSCSI 目标以使 CHAP 密码生效。
注: 在以上的示例中,xxxxxxxxxxxxx 是主机的 CHAP 密钥,而 rhel_username 是启动器的 IQN 名称。该用户名必须是使用 chhost 命令(iscsiusername 字段)为该主机设置的相同值。 - 设置发起程序名称的 CHAP 用户名和密码。
- 设置双向认证。注: 并非必须设置双向认证。在您为双向认证进行配置之前,确保您已配置了单向认证且此认证对您的主机有效。
- 将 password_in 更改为您在系统上使用 chsystem 命令设置的 CHAP 密码。
- 设置一个或多个目标的 CHAP 用户名和密码。
- node.session.auth.password_in = <CHAP secret for clustered system>
- 设置一个或多个目标的发现会话 CHAP 用户名和密码。
- discovery.sendtargets.auth.password_in = <CHAP secret for clustered system>
- 设置一个或多个目标的 CHAP 用户名和密码。
- 保存这些设置。您必须注销任何当前会话并重新发现系统 iSCSI 目标以使 CHAP 密码生效。
- 将 password_in 更改为您在系统上使用 chsystem 命令设置的 CHAP 密码。
- 设置单向认证: