配置管理员使用RADIUS+Local方式认证并授权用户级别示例
组网需求
- 管理员输入正确的用户名和密码才能通过STelnet登录设备。
- 管理员通过STelnet登录设备后,服务器授权用户级别为15级,可以执行命令级别为0~15的所有命令行。
当服务器不回应设备的认证请求时(例如,设备和服务器之间链路中断时),管理员登录设备时转为Local认证。
配置思路
- 在Switch上配置STelnet登录:配置VTY界面的认证方式为AAA、使能STelnet服务、配置SSH用户的认证方式和服务方式。
- 在Switch上配置RADIUS认证:创建RADIUS服务器模板,配置AAA方案、配置全局默认管理域。
- 在Switch上配置本地用户:配置本地用户名和密码、配置本地用户级别。
- 配置RADIUS服务器。
注意事项
- 配置前请确保各设备之间路由可达。
请确保RADIUS服务器模板内的共享密钥和RADIUS服务器上的配置保持一致。
- 如果登录的账号在RADIUS服务器上没有创建,但是在本地存在。RADIUS认证时,将被认为认证失败,不再转入本地认证。只有在RADIUS服务器Down或者无响应时,才会转入本地认证。
- 如果计费方案配置计费模式为RADIUS,为避免设备和服务器之间链路中断后,管理员用户本地认证通过,而开始计费失败导致用户登录失败,所以需要在计费方案下配置命令:accounting start-fail online,确保初始计费失败后允许用户上线。
如果RADIUS服务器不接受包含域名的用户名,可以在RADIUS服务器模板视图下,配置命令undo radius-server user-name domain-included使设备向RADIUS服务器发送的报文中的用户名不包含域名。
- 域被配置成全局默认管理域之后,管理用户的用户名中携带该域名或者不携带域名时,会使用全局默认管理域下的AAA配置信息。
- 配置命令undo radius-server user-name domain-included后,设备仅会修改发送报文中的用户名格式,不会影响用户所属的域。例如,配置该命令后,用户名为“user@example.com”的用户仍使用example.com域下的AAA配置信息。
- 使用RADIUS扩展属性HW-Exec-Privilege(26-29)来授权管理员用户的优先级时,有效值范围是0~15。取值大于等于16为无效值。
操作步骤
- 配置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
- 配置RADIUS认证。
# 配置RADIUS服务器模板,实现与RADIUS服务器的通信。
[Switch] radius-server template 1 [Switch-radius-1] radius-server authentication 10.1.6.6 1812 [Switch-radius-1] radius-server accounting 10.1.6.6 1813 [Switch-radius-1] radius-server shared-key cipher Example@123 [Switch-radius-1] quit
# 配置AAA认证方案,指定认证方式为RADIUS+Local。
[Switch] aaa [Switch-aaa] authentication-scheme sch1 [Switch-aaa-authen-sch1] authentication-mode radius local [Switch-aaa-authen-sch1] quit
# 配置计费方案acc1,指定计费方式为RADIUS计费。
[Switch-aaa] accounting-scheme acc1 [Switch-aaa-accounting-acc1] accounting-mode radius [Switch-aaa-accounting-acc1] accounting start-fail online [Switch-aaa-accounting-acc1] quit
# 在域下引用AAA认证方案、RADIUS服务器模板。
[Switch-aaa] domain example.com [Switch-aaa-domain-example.com] authentication-scheme sch1 [Switch-aaa-domain-example.com] accounting-scheme acc1 [Switch-aaa-domain-example.com] radius-server 1 [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
- 配置RADIUS服务器
配置步骤包括:添加设备、添加用户、配置用户级别为15级。
- 验证配置结果
- 管理员通过STelnet客户端软件登录交换机。
输入RADIUS服务器上配置的用户名user1和密码Example@123,验证通过,用户成功通过STelnet登录到交换机。
- 在交换机与RADIUS服务器链路正常的情况下,在交换机上执行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级、认证类型为管理员认证、认证方法为RADIUS。
<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 : Switch255255000000000f****2016009 Option82 information : - User access type : SSH User Privilege : 15 AAA: User authentication type : Administrator authentication Current authentication method : RADIUS Current authorization method : - Current accounting method : RADIUS ------------------------------------------------------------------------------
- 在交换机与RADIUS服务器链路中断的情况下,在交换机上执行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。
<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 : Switch255255000000000f****2016009 Option82 information : - User access type : SSH User Privilege : 15 AAA: User authentication type : Administrator authentication Current authentication method : Local Current authorization method : - Current accounting method : RADIUS ------------------------------------------------------------------------------
- 管理员通过STelnet客户端软件登录交换机。
配置文件
Switch的配置文件
#
sysname Switch
#
radius-server template 1
radius-server shared-key cipher %^%#Q75cNQ6IF(e#L4WMxP~%^7'u17,]D87GO{"[o]`D%^%#
radius-server authentication 10.1.6.6 1812 weight 80
radius-server accounting 10.1.6.6 1813 weight 80
#
aaa
authentication-scheme sch1
authentication-mode radius local
accounting-scheme acc1
accounting-mode radius
accounting start-fail online
domain example.com
authentication-scheme sch1
accounting-scheme acc1
radius-server 1
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