配置管理员使用HWTACACS+Local方式认证并授权用户级别示例
组网需求
- 管理员输入正确的用户名和密码才能通过STelnet登录设备。
- 管理员通过STelnet登录设备后,授权管理员级别为15级。
当服务器不回应设备的认证请求时(例如,设备和服务器之间链路中断时),管理员登录设备时转为Local认证。
配置思路
- 在Switch上配置STelnet登录:配置VTY界面的认证方式为AAA、使能STelnet服务、配置SSH用户的认证方式和服务方式。
- 在Switch上配置HWTACACS认证:创建HWTACACS服务器模板,配置AAA方案,配置全局默认管理域。
- (可选)在Switch上配置用户提升级别的方式。
- 在Switch上配置本地用户。
- 配置HWTACACS服务器。
注意事项
- 配置前请确保各设备之间路由可达。
请确保HWTACACS服务器模板内的共享密钥和HWTACACS服务器上的配置保持一致。
- 如果登录的账号在服务器上没有创建,但是在本地存在。HWTACACS认证时,将被认为认证失败,不再转入本地认证。只有在服务器Down或者无响应时,才会转入本地认证。
- 如果计费方案配置计费模式为HWTACACS,为避免设备和服务器之间链路中断后,管理员用户本地认证通过,而开始计费失败导致用户登录失败,所以需要在计费方案下配置命令:accounting start-fail online,确保初始计费失败后允许用户上线。
- 当使用super命令从高级别往低级别或相同级别间切换时,切换行为不需要通过任何认证;从低级别往高级别切换时,切换行为需要进行认证,只有认证通过,才赋予该用户新的级别。
操作步骤
- 配置STelnet登录
# 在服务器端生成本地密钥对。
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] dsa local-key-pair create Info: The key name will be: Switch_Host_DSA. Info: The key modulus can be any one of the following : 1024, 2048. Info: If the key modulus is greater than 512, it may take a few minutes. Please input the modulus [default=2048]: Info: Generating keys... Info: Succeeded in creating the DSA host keys.
# 配置VTY用户界面0~14的认证方式为AAA认证、支持的协议为SSH。
[Switch] user-interface vty 0 14 [Switch-ui-vty0-14] authentication-mode aaa [Switch-ui-vty0-14] protocol inbound ssh [Switch-ui-vty0-14] quit
# 开启设备的SSH服务器功能。
[Switch] stelnet server enable
# 配置所有SSH用户的认证方式为Password认证、服务方式为STelnet。
[Switch] ssh authentication-type default password
如果仅某几个SSH用户的认证方式为Password认证、服务方式为STelnet,可以通过指定SSH用户名的形式配置。例如:指定用户名为admin的SSH用户的认证方式为Password认证、服务方式为STelnet。
[Switch] ssh user admin authentication-type password
[Switch] ssh user admin service-type stelnet
- 配置HWTACACS认证
# 配置HWTACACS服务器模板template1,实现设备与HWTACACS服务器的通信。
[Switch] hwtacacs enable [Switch] hwtacacs-server template template1 [Switch-hwtacacs-template1] hwtacacs-server authentication 10.1.6.6 49 [Switch-hwtacacs-template1] hwtacacs-server authorization 10.1.6.6 49 [Switch-hwtacacs-template1] hwtacacs-server accounting 10.1.6.6 49 [Switch-hwtacacs-template1] hwtacacs-server shared-key cipher Hello@1234 [Switch-hwtacacs-template1] quit
# 配置认证方案sch1,指定认证方式为HWTACACS+Local认证。
[Switch] aaa [Switch-aaa] authentication-scheme sch1 [Switch-aaa-authen-sch1] authentication-mode hwtacacs local [Switch-aaa-authen-sch1] quit
# (可选)配置用户提升级别模式为HWTACACS Local。
[Switch-aaa-authen-sch1] authentication-super hwtacacs super [Switch-aaa-authen-sch1] quit
# 配置授权方案sch2,指定授权方式为HWTACACS+Local授权。
[Switch-aaa] authorization-scheme sch2 [Switch-aaa-author-sch2] authorization-mode hwtacacs local [Switch-aaa-author-sch2] quit
# 配置计费方案sch3,指定计费方式为HWTACACS计费。
[Switch-aaa] accounting-scheme sch3 [Switch-aaa-accounting-sch3] accounting-mode hwtacacs [Switch-aaa-accounting-sch3] accounting start-fail online [Switch-aaa-accounting-sch3] quit
# 在域example.com下引用HWTACACS服务器模板和AAA方案。
[Switch-aaa] domain example.com [Switch-aaa-domain-example.com] hwtacacs-server template1 [Switch-aaa-domain-example.com] authentication-scheme sch1 [Switch-aaa-domain-example.com] authorization-scheme sch2 [Switch-aaa-domain-example.com] accounting-scheme sch3 [Switch-aaa-domain-example.com] quit [Switch-aaa] quit
# 配置域example.com为全局默认管理域。
[Switch] domain example.com admin
- 配置本地认证
# 配置本地账号“user1”,密码“Example@123”,级别为15级。
[Switch] aaa [Switch-aaa] local-user user1 password irreversible-cipher Example@123 [Switch-aaa] local-user user1 service-type ssh [Switch-aaa] local-user user1 privilege level 15 [Switch-aaa] return
- 配置HWTACACS服务器
配置步骤包括:添加设备、添加用户、配置用户级别为15级。
(可选)如果需要允许管理员提升级别,则服务器需要配置最大级别为15,同时下发初始级别为10。
- 验证配置结果
- 管理员通过STelnet客户端软件登录交换机。
输入HWTACACS服务器上配置的用户名user1和密码Example@123,验证通过,用户成功通过STelnet登录到交换机。
- 当交换机与服务器链路正常时,在交换机上执行display access-user username user-name detail,查看用户user1的信息。User access type、User Privilege、User authentication type、Current authentication method、Current authorization method、Current accounting method分别表示用户的登录方式为SSH、用户级别为10级、认证类型为管理员认证、认证授权和计费方法为HWTACACS。
<Switch> display access-user username user1 detail ------------------------------------------------------------------------------ Basic: User ID : 11 User name : user1 Domain-name : example.com User MAC : - User IP address : 10.1.1.10 User IPv6 address : - User access time : 2019/07/10 09:15:02 User accounting session ID : example255255000000000f****2016009 Option82 information : - User access type : SSH User Privilege : 10 AAA: User authentication type : Administrator authentication Current authentication method : HWTACACS Current authorization method : HWTACACS Current accounting method : HWTACACS ------------------------------------------------------------------------------
- 将管理员级别由10级提升为15级。
<Switch> super 15 Password: Now user privilege is 15 level, and only those commands whose level is equal to or less than this level can be used. Privilege note: 0-VISIT, 1-MONITOR, 2-SYSTEM, 3-MANAGE
- 在交换机与服务器链路中断的情况下,在交换机上执行display access-user username user-name detail,查看用户user1的信息。User access type、User Privilege、User authentication type、Current authentication method、Current authorization method、Current accounting method分别表示用户的登录方式为SSH、用户级别为15级、认证类型为管理员认证、认证和授权方法为LOCAL、计费方法为HWTACACS。
<Switch> display access-user username user1 detail ------------------------------------------------------------------------------ Basic: User ID : 11 User name : user1 Domain-name : example.com User MAC : - User IP address : 10.1.1.10 User IPv6 address : - User access time : 2019/07/10 09:20:02 User accounting session ID : example255255000000000f****2016009 Option82 information : - User access type : SSH User Privilege : 15 AAA: User authentication type : Administrator authentication Current authentication method : Local Current authorization method : Local Current accounting method : HWTACACS ------------------------------------------------------------------------------
- 管理员通过STelnet客户端软件登录交换机。
配置文件
Switch的配置文件
# sysname Switch # hwtacacs-server template template1 hwtacacs-server authentication 10.1.6.6 hwtacacs-server authorization 10.1.6.6 hwtacacs-server accounting 10.1.6.6 hwtacacs-server shared-key cipher %^%#)@1e81]jJP9}9O9|W>MT|TWbI,\rL4[.BT&@);rU%^%# # aaa authentication-scheme sch1 authentication-mode hwtacacs local authorization-scheme sch2 authorization-mode hwtacacs local accounting-scheme sch3 accounting-mode hwtacacs accounting start-fail online domain example.com authentication-scheme sch1 accounting-scheme sch3 authorization-scheme sch2 hwtacacs-server template1 local-user user1 password irreversible-cipher $1a$&YTv-xg$H<$Rj=5*sUqT+0i<B<0lAELMMraNPQAp'cD1!N~mjNI$ local-user user1 privilege level 15 local-user user1 service-type ssh # user-interface vty 0 14 authentication-mode aaa # stelnet server enable # return