Netmiko 最简单的连接:
from netmiko import ConnectHandler ip = "10.0.0.1" username = "admin" password = "admin" secret = "huawei" device_type = "huawei_telnet" # ruijie_os 后面加_telnet 则使用telnet连接 port = 23 #ssh 默认端口22 telnet默认端口23 device = {"host": ip, # 设备ip地址 必要参数 "device_type":device_type, # 设备类型 必要参数 "username": username, "password": password, "secret":secret, "port":port } conn = ConnectHandler(**device) #查看设备配置 output = conn.send_command('disp cu', strip_command=False, strip_prompt=False) #输出内容 print(output) #断开连接 conn.disconnect()