华为交换机中用户登陆相关配置


以下情况都是在华为S5700交换机下演示,不同型号交换机和路由器具体配置略有不同。

登陆交换机,目前方式有:

  • 通过console线直连交换机登陆
  • MiniUse口直连交换机登陆
  • web网管页面登陆
  • telnet远程登陆
  • ssh远程登陆
1. 首次使用console口登陆配置
  • 情况一: 默认账号密码,不同型号的账号和密码不同,比如: admin / admin@huawei.com

  • 情况二: 无账号密码。

    以下说下,无账号密码情况,设置账号密码

1. 配置使用密码登陆

不用输入用户名,仅凭密码登陆

注意: #号后面的都是注释信息,无关配置。

[Huawei]user-interface console  0   #指定console口编号,只能为0

[Huawei-ui-console0]authentication-mode password #指定该接口采用password认证方式。

[Huawei-ui-console0]d th
#
user-interface con 0
 authentication-mode password
 set authentication password cipher s{pi(+f+c%uqcXT}k'OIh~3#
user-interface vty 0 4
return
# password加密方式有cipher和simple,其他aaa视图下还有irreversible-cipher。
  • cipher: 在交换机中以密文存储。建议使用
  • simple:在交换机中以明文存储。不建议使用
  • irreversible-cipher: 使用不可逆的算法,以密码存储。建议使用。

值得一提的是:set authentication password 是和authentication-mode password挂钩的,如果认证模式选择aaa, 这样设置密码是不起作用的。需要在AAA视图下,另行设置。

2. 配置使用AAA认证方式

仅凭密码的登陆方式,安全性一定不如使用账号和密码人生的方式。所以在配置交换机时,可以采用AAA认证方式。

注意: 先创建AAA用户,再去操作console接口配置,防止中途断联。

[Huawei]aaa  #进入AAA视图
[Huawei]local-user admin password cipher 123456 #配置自带的用户admin,密码设置为123456
[Huawei]local-user admin privilege level 15 #级别设置为最高15.
[Huawei] local-user admin service-type telnet terminal ssh # 允许服务类型为telnet,终端和ssh方式。

[Huawei-aaa]local-user  paopao  password  cipher 123456  privilege level  15  idle-timeout  10  
#新增一个用户,用户名为paopao, 密码123456 ,级别15, 超过10分钟无操作,自动断开。默认是10分钟
Info: Add a new user.

[Huawei-aaa]local-user paopao service-type  terminal  ssh telnet 
[Huawei-aaa]d th #查看当前配置
# 
aaa
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default
 domain default_admin
 local-user admin password cipher %NS[+B0ZNI]NZPO3JBXBHA!!
 local-user admin privilege level 15
 local-user admin service-type telnet terminal ssh
 local-user paopao password cipher %NS[+B0ZNI]NZPO3JBXBHA!! idle-timeout 10 0
 local-user paopao privilege level 15
 local-user paopao service-type telnet terminal ssh
#
return

[Huawei]user-interface console  0   
[Huawei-ui-console0]undo set authentication password 
# 切换时,先删除之前配置的密码。

[Huawei-ui-console0]authentication-mode aaa #指定该接口采用AAA认证方式。

[Huawei-ui-console0]user privilege level  3 #默认的级别也是3,所有查看时,看不到这条配置信息。

[Huawei-ui-console0]d th #查看配置
#
user-interface con 0
 authentication-mode aaa
user-interface vty 0 4
#
return

在这里插入图片描述

验证如上。

3. console用户界面管理
  • 查看当前所有登陆过的用户信息

    <Huawei>dis users
      User-Intf    Delay    Type   Network Address     AuthenStatus    AuthorcmdFlag
    + 0   CON 0   00:00:00                                   pass           no      
      Username : paopao
    

    用户paopao通过console 0口登陆,认证通过。

  • 查看特定接口的用户信息,如console 0口

    <Huawei>dis user-interface console 0 
      Idx  Type     Tx/Rx      Modem Privi ActualPrivi Auth  Int     
    + 0    CON 0    9600       -     3     15          A     -       
      +    : Current UI is active.
      F    : Current UI is active and work in async mode.
      Idx  : Absolute index of UIs.
      Type : Type and relative index of UIs.
      Privi: The privilege of UIs.
      ActualPrivi: The actual privilege of user-interface.
      Auth : The authentication mode of UIs.
          A: Authenticate use AAA.
          N: Current UI need not authentication.
          P: Authenticate use current UI's password.
      Int  : The physical location of UIs.
    

    上面信息可以看出:

    • 使用该console口,是AAA模式

    • 传输速率9600bit/s

    • 当前实际登陆用户级别是15,该接口级别为3.

    • +号表示为当前活跃用户

  • 查看交换机已配置的所有用户信息摘要

    <Huawei>dis local-user 
      ----------------------------------------------------------------------------
      User-name                      State  AuthMask  AdminLevel  
      ----------------------------------------------------------------------------
      admin                          A      TMS       15         
      paopao                         A      TMS       15         
      ----------------------------------------------------------------------------
      Total 2 user(s)
    
  • 部分型号,有kill命令,可以断开指定的接口连接

    <HUAWEI>kill user-interface  ?
      INTEGER<0-104>  Specify a user terminal interface and configure it
      console         Primary user terminal interface
      nca             The NETCONF user interface
      vty             The virtual user terminal interface
    

VTY是一个虚拟用户界面,它不像console用户界面那样通过物理连接实现,而是通过网络连接建立虚拟通道实现,而且可以建立多条VTY虚拟通过,可实现远程维护的需求,如通过telnet,ssh等。

2. VTY用户界面配置
1. 配置VTY用户界面最大个数

默认最大是5个,从0开始计数,VTY0-4.

VTY最多可以配置成15个

[Huawei-ui-vty3]dis user-interface  maximum-vty 
 Maximum of VTY user:4  #最大4个,vty0-3.
 
[Huawei]user-interface maximum-vty  15 #设置为最大为15个,vty0-14

每个vty口可以单独配置,也可以批量配置相同策略。

如果在vty接口下配置了telnet或ssh登陆,这时候想在不删除配置的情况下,禁用部分vty接口,可以使用undo shell命令

[Huawei]user-interface vty 0 3
[Huawei-ui-vty0-3]undo shell
Warning: ui-vty0-3 will be disabled. Continue? [Y/N]:y

重启启用,也简单,直接shell.

2. VTY用户界面登陆方式之telnet
[test1]user-interface vty  0 3 #0,1,2,3 总共4个vty接口。
[test1-ui-vty0-3]authentication-mode aaa #设置认证方式为AAA认证,类似console口,也有password认证模式,具体配置同console.
[test1-ui-vty0-3]protocol inbound telnet #配置vty用户界面支持telnet。可选有ssh(缺省默认), all,all表示支持所有协议。
[test1-ui-vty0-3]d th
#
user-interface con 0
user-interface vty 0 3
 authentication-mode aaa
user-interface vty 4
#
return
[test1-aaa]local-user didi pas	
[test1-aaa]local-user didi password ?
  cipher  User password with cipher text
  simple  User password with plain text

[test1-aaa]local-user didi password cipher 123456 #为telnet新增用户
Info: Add a new user.
[test1-aaa]local-user didi privilege level 15 
[test1-aaa]local-user didi service-type telnet ssh
[test1-aaa]d th
#
aaa
 authentication-scheme default
 authorization-scheme default
 accounting-scheme default
 domain default
 domain default_admin
 local-user didi password cipher %NS[+B0ZNI]NZPO3JBXBHA!!
 local-user didi privilege level 15
 local-user didi service-type telnet ssh
 local-user admin password simple admin
 local-user admin service-type http
#
return

[test1]dis telnet server status #查看telnet server状态没,如果是disable状态,说明还需要配置telnet server服务。
 TELNET IPv4 server                       :Disable
 TELNET IPv6 server                       :Enable
 TELNET server port                       :23
[test1]telnet server enable #启用telnet server.

可以说,基本上telnet配置和console口的配置大体相同。

另外一提: 如果当前有其他终端使用telnet连接交换机,那么交换机无法使用undo telnet server enable命令,原因就是有连接已建立。

3. Telnet server相关设置
  • 设置telnet server端口,修改后将断开所有telnet现有连接。

    [test1]telnet server port 1500
    
  • 部分型号,可以指定acl进行telnet server策略。

    [*sw-acl4-advance-3000]rule 5 permit  ip source 192.168.1.1 0  #仅运行192.168.1.1。
    [~sw]telnet server acl 3000  #telnet server应用acl
    
    #这样就只能在192.168.1.1上使用telnet本交换机。
    
  • telnet server-source -i指定环回口作为telnet server的源接口。

4. VTY用户界面下配置acl策略

在VTY下可以配置策略,这样就不用单独在telnet或ssh 服务下配置策略了。

  • 入策略
[test1-acl-adv-3000]rule permit  ip source  192.168.1.1 0  #acl 3000 添加一条规则
[test1-ui-vty0-4]acl  3000   inbound  #vty 0 4界面应用acl3000策略
  • 出策略

    [test1-acl-adv-3001]rule permit  ip source  192.168.1.1 0 destination-port eq telnet  #acl 3001 添加一条规则
    [test1-ui-vty0-4]acl  3001   outbound  #vty 0 4界面应用acl3001策略
    

    这样本设备无法访问192.168.1.1的telnet服务(默认23端口)

5. VTY用户级别和访问权限规则
  • 如果vty用户界面下配置的用户级别访问与用户名(AAA)本身对应权限冲突,以用户名自身的命令级别为准。

  • 如果是password和none方式,那么登陆到该设备的用户所能访问的命令级别权限与登陆时VTY用户界面下的级别设定一致

    [test1-ui-vty0-4]user privilege level 0 #这种情况下就只有级别0
    
6. VTY用户界面登陆之SSH

华为交换机支持多种ssh认证方式

认证方式描述
Password用户名+口令方式认证,当使用password认证,需要在aaa视图下,配置和ssh user同名用户。
RSA、DSA、ECC认证时,需要ssh 客户端生成的公钥,提前保存到交换机server端上,这样客户端登陆时,客户端自身持有的私钥和交换机公钥相验证。
Password-RSA、Password-DSA、Password-ECC同时配置以上两种认证方式,用户名+口令+密钥
7. 配置ssh之password认证
[test1]aaa
[test1-aaa]local-user  thecan password  cipher  123456 #新增用户
Info: Add a new user.
[test1-aaa]local-user  thecan service-type ssh #用户支持ssh
[test1-aaa]local-user thecan privilege  level 3 #用户级别为3
[test1]user-interface vty 0 4
[test1-ui-vty0-4]authentication-mode aaa #vty配置aaa认证模式。
[test1-ui-vty0-4]protocol inbound all #运行 ssh和telnet协议流量。
[test1]ssh  user  thecan  #新增ssh用户,与aaa视图下thecan用户同名
Info: Succeeded in adding a new SSH user.
[test1]ssh user thecan  authentication-type password #ssh认证方式为password: 用户名+口令
[test1]ssh user thecan service-type  stelnet #配置ssh用户的服务方式
[test1]dis ssh user-information
  User 1:
       User Name            : thecan
       Authentication-type  : password
       User-public-key-name : -
       User-public-key-type : -
       Sftp-directory       : -
       Service-type         : stelnet
       Authorization-cmd    : No
[test1]stelnet  server  enable #启用ssh server
Info: Succeeded in starting the Stelnet server.
[test1]dis ssh server status
 SSH version                         :1.99
 SSH connection timeout              :60 seconds
 SSH server key generating interval  :0 hours
 SSH authentication retries          :3 times
 SFTP server                         :Disable
 Stelnet server                      :Enable #启用了
 Scp server                          :Disable 
 [SW1]rsa local-key-pair create #不管password认证还是rsa认证,交换机都应该生成本地密钥。

使用putty连接,cmd下的不行。

注意点:

  • 配置ssh server 开启

  • 配置ssh用户

  • 配置aaa下同名用户

  • vty配置aaa认证模式,并放通ssh。

  • 交换机设备本地生成密钥对

  • 使用putty连接,否则可能报错

    - Unable to negotiate with 192.168.136.201 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
    

在这里插入图片描述

  • 5
    点赞
  • 105
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值