华为telnet连接(无用户名登录和aaa模板登录)

实验拓扑(下载地址)

华为telnet连接(无用户名登录和aaa模板登录)

图 1-1

注:如无特别说明,描述中的 R1 或 SW1 对应拓扑中设备名称末尾数字为 1 的设备,R2 或 SW2 对应拓扑中设备名称末尾数字为 2 的设备,以此类推;另外,同一网段中,IP 地址的主机位为其设备编号,如 R3 的 g0/0 接口若在192.168.1.0/24网段,则其 IP 地址为192.168.1.3/24,以此类推


实验需求

  1. 按照图示配置 IP 地址,

  2. 2在AR1上配置telnet服务,使AR2可以使用telnet远程登录AR1


实验解法

  1. 配置 IP 地址部分

AR1

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys ar1
[ar1]int g0/0/0
[ar1-GigabitEthernet0/0/0]ip add 192.168.2.2 24

PC2

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn ar2
[ar2]int g0/0/0
[ar2-GigabitEthernet0/0/0]ip add 192.168.1.2 24
[ar2]un in en            //关闭系统通知,要不然会刷屏
Info: Information center is disabled.

2,在AR1上配置telnet服务,使AR2可以使用telnet远程登录AR3,设置登录用户为5人

AR1

[R1]telnet server enable 
 Error: TELNET server has been enabled                    /华为TELNET服务一般默认开启
[R1]user-int vty 0 4                                      /登录人数限制0 1 2 3 4 正好5个
[R1-ui-vty0-4]authentication-mode password 
Please configure the login password (maximum length 16):10                //设置密码长度,最长为16
[R1-ui-vty0-4]set  authentication password cipher yueye                 /设置登录密码为密文方式密码为yueye
[R1-ui-vty0-4]user pr lenve 15   /设置用户等级,否则无法修改配置,远程状态下。

3,登录测试

AR2

<r2>telnet 192.168.1.1                                   //要在用户视图下登录
  Press CTRL_] to quit telnet mode
  Trying 192.168.1.1 ...
  Connected to 192.168.1.1 ...
Login authentication 
Password:                                                  //此方法为无用户名登录
<R1>                                           //登录成功后发现设备名称变化

4,补充aaa登录配置

AR1

步骤1:设置AR1的telnet认证方式为aaa

[r1]user-int vty 0 4
[r1-ui-vty0-4]authentication-mode aaa

步骤2:配置aaa登录用户模板应用服务与权限等级

[R1-ui-vty0-4]aaa
[R1-aaa]local-user yueye pas ci 123     //创建用户月夜密码为密文的123
Info: Add a new user.
[R1-aaa]local yueye pr le 15          //配置用户等级为15级
[R1-aaa]loca yueye ser tel               //应用服务为telnet

AR2登录测试(会发现需要用户名称与密码才能登录)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Python是一种高级编程语言,它被广泛应用于各种领域,包括网络编程。在Python中,可以使用telnetlib库来实现telnet登录华为交换机,并批量修改登录用户名密码。 下面是一个简单的示例代码,演示如何使用Python批量修改华为交换机telnet登录用户名密码: ```python import telnetlib # 定义交换机的IP地址和端口号 host = "192.168.1.1" port = 23 # 定义登录用户名密码 username = "admin" password = "password" # 定义新的用户名密码 new_username = "new_admin" new_password = "new_password" # 创建telnet连接 tn = telnetlib.Telnet(host, port) # 登录交换机 tn.read_until(b"Username:") tn.write(username.encode('ascii') + b"\n") tn.read_until(b"Password:") tn.write(password.encode('ascii') + b"\n") # 修改用户名 tn.read_until(b">") tn.write(b"system-view\n") tn.read_until(b"[Switch]") tn.write(b"user-interface vty 0 4\n") tn.read_until(b"[Switch-ui-vty0-4]") tn.write(b"user privilege level 3\n") tn.read_until(b"[Switch-ui-vty0-4]") tn.write(b"authentication-mode aaa\n") tn.read_until(b"[Switch-ui-vty0-4]") tn.write(b"quit\n") tn.read_until(b"[Switch]") tn.write(b"aaa\n") tn.read_until(b"[Switch-aaa]") tn.write(b"local-user " + username.encode('ascii') + b" password cipher " + password.encode('ascii') + b"\n") tn.read_until(b"[Switch-aaa]") tn.write(b"local-user " + username.encode('ascii') + b" privilege level 3\n") tn.read_until(b"[Switch-aaa]") tn.write(b"local-user " + new_username.encode('ascii') + b" password cipher " + new_password.encode('ascii') + b"\n") tn.read_until(b"[Switch-aaa]") tn.write(b"local-user " + new_username.encode('ascii') + b" privilege level 3\n") tn.read_until(b"[Switch-aaa]") tn.write(b"quit\n") # 保存配置并退出 tn.read_until(b"[Switch]") tn.write(b"save\n") tn.read_until(b"[Switch]") tn.write(b"quit\n") # 关闭telnet连接 tn.close() print("用户名密码修改成功!") ``` 请注意,上述代码仅供参考,实际使用时需要根据具体的华为交换机型号和配置进行相应的修改。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月夜行舟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值