华为设备开启telnet
user-interface vty 0 4
authentication-mode aaa
user privilege level 15
protocol inbound all
telnet server enable
aaa
local-user test password cipher test
local-user test service-type telnet
python
# -*- coding: gb2312 -*-
import telnetlib
import time
HOST = "192.168.0.1"
user = "test"
password = "test"
def command(con, flag, str_=""):
data = con.read_until(flag.encode())
print(data.decode('gb2312', errors='ignore'), end="")
# errors -- 设置不同错误的处理方案。 end="" 输出不做换行处理
con.write(str_.encode() + b"\n")
tn = telnetlib.Telnet(HOST, port=23)
command(tn, "Username:", user)
if password:
command(tn, "Password:", password)
command(tn, ">", "sys")
command(tn, "]", )
time.sleep(2)
tn.close()

博客内容主要围绕使用Python开启华为设备的Telnet功能,涉及信息技术中后端开发与网络管理相关内容,通过Python脚本可实现对华为设备Telnet的开启操作。
1509

被折叠的 条评论
为什么被折叠?



