码迷,mamicode.com
首页 > Web开发 > 详细

netmiko & huawei

时间:2020-06-05 22:36:46      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:start   current   spec   cat   div   base   vrp   ice   image   

from netmiko import ConnectHandler
import logging
logging.basicConfig(filename="test.log", level=logging.DEBUG)
huawei = {‘device_type‘: ‘huawei‘, ‘ip‘: ‘10.10.30.253‘, ‘username‘: ‘root@default‘, ‘password‘: ‘Admin123_.‘,‘port‘: 22}
#huawei = {‘device_type‘: ‘huawei_vrpv8‘, ‘ip‘: ‘10.10.30.253‘, ‘username‘: ‘root@default‘, ‘password‘: ‘Admin123_.‘,‘port‘: 22}
net_connect = ConnectHandler(**huawei)
sshConfirm = net_connect.find_prompt()
print(‘login ‘ + sshConfirm)
#current_view = net_connect.find_prompt()
#print(current_view)
commands = [‘dis arp‘]
output = net_connect.send_config_set(commands)
## not support commit
#output += net_connect.commit()
print(output)
net_connect.disconnect()
[root@bogon ironic]#

[root@bogon ironic]# cat test.log 
DEBUG:paramiko.transport:starting thread (client mode): 0x8f9c0290L
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.7.1
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0--
INFO:paramiko.transport:Connected (version 2.0, client -)
DEBUG:paramiko.transport:kex algos:[udiffie-hellman-group-exchange-sha256, uecdh-sha2-nistp521, uecdh-sha2-nistp384, uecdh-sha2-nistp256, udiffie-hellman-group-exchange-sha1, usm2kep-sha2-nistp256] server key:[ussh-dss, ussh-rsa, uecdsa-sha2-nistp521] client encrypt:[uaes256-ctr, uaes128-ctr] server encrypt:[uaes256-ctr, uaes128-ctr] client mac:[uhmac-sha2-256, uhmac-sha2-256-96, uhmac-sha1-96] server mac:[uhmac-sha2-256, uhmac-sha2-256-96, uhmac-sha1-96] client compress:[unone, uzlib] server compress:[unone, uzlib] client lang:[u‘‘] server lang:[u‘‘] kex follows?False
DEBUG:paramiko.transport:Kex agreed: ecdh-sha2-nistp256
DEBUG:paramiko.transport:HostKey agreed: ecdsa-sha2-nistp521
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ecdsa-sha2-nistp521 host key for 10.10.30.253: b6d87e3a5fee634c324c9699dcb14012
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Authentication (password) successful!
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:netmiko:read_channel: 
Warning: The initial password poses security risks.
The password needs to be changed. Change now? [Y/N]:
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:In set_base_prompt
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: 

DEBUG:netmiko:read_channel: 
Error: Please choose YES or NO first before pressing Enter. [Y/N]:
DEBUG:netmiko:write_channel: 

DEBUG:netmiko:read_channel: 
Error: Please choose YES or NO first before pressing Enter. [Y/N]:
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:read_channel: 
DEBUG:netmiko:write_channel: return

DEBUG:netmiko:Pattern is: >
DEBUG:netmiko:write_channel: exit

DEBUG:paramiko.transport:EOF in transport thread
[root@bogon ironic]# 

 

67         if "[Y/N]" in prompt:
 68             log.debug("First time logging in")
 69             self.write_channel("N"+self.RETURN)
 70             return self.base_prompt

技术图片

 

netmiko & huawei

标签:start   current   spec   cat   div   base   vrp   ice   image   

原文地址:https://www.cnblogs.com/dream397/p/13052506.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!