Python连接测试
1.需求:连接H3C S6805 获取配置文件信息并写入a.txt中。2.配置S6805能够通过ssh访问:


3.编写代码: from netmiko import ConnectHandler as ch
import os
import shutil
host = {
'device_type': 'hp_comware',
'host': '192.168.18.195',
'username': 'admin',
'password': 'Huawei@123',
'port': 22,
'secret': '',
}
conn = ch(**host)
output = conn.send_command('display cu')
print(output)
with open('/Users/jiapengsu/PycharmProjects/Fish/venv/a.txt', 'w') as file:
file.write(output)

4.检查效果:

