[root@bogon good]# vi huawei.248.py 1 from netmiko import ConnectHandler 2 import logging 3 logging.basicConfig(filename="test.log", level=logging.DEBUG) 4 huawei = {‘device_type‘: ‘huawei‘, ‘ip‘: ‘10.10.17.248‘, ‘username‘: ‘root@default‘, ‘password‘: ‘xxx.‘, ‘port‘: 22} 5 net_connect = ConnectHandler(**huawei) 6 sshConfirm = net_connect.find_prompt() 7 print(‘login ‘ + sshConfirm) 8 commands = [‘dis version‘] 9 output = net_connect.send_config_set(commands) 10 print(output) 11 net_connect.disconnect()
[root@bogon good]# python huawei.248.py Traceback (most recent call last): File "huawei.248.py", line 5, in <module> net_connect = ConnectHandler(**huawei) File "/usr/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 246, in ConnectHandler return ConnectionClass(*args, **kwargs) File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 317, in __init__ self._open() File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 323, in _open self._try_session_preparation() File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 738, in _try_session_preparation self.session_preparation() File "/usr/lib/python2.7/site-packages/netmiko/huawei/huawei.py", line 15, in session_preparation self.disable_paging(command="screen-length 0 temporary") File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 1015, in disable_paging output = self.read_until_prompt() File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 605, in read_until_prompt return self._read_channel_expect(*args, **kwargs) File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 543, in _read_channel_expect "Timed-out reading channel, data not available." netmiko.ssh_exception.NetMikoTimeoutException: Timed-out reading channel, data not available.
[root@bogon good]# vi huawei.248.py 1 from netmiko import ConnectHandler 2 import logging 3 logging.basicConfig(filename="test.log", level=logging.DEBUG)xxx 4 huawei = {‘device_type‘: ‘huawei‘, ‘ip‘: ‘10.10.17.248‘, ‘username‘: ‘root@default‘, ‘password‘: ‘ xxxxx‘, ‘port‘: 23} 5 net_connect = ConnectHandler(**huawei) 6 sshConfirm = net_connect.find_prompt() 7 print(‘login ‘ + sshConfirm) 8 commands = [‘dis version‘] 9 output = net_connect.send_config_set(commands) 10 print(output) 11 net_connect.disconnect() huawei.248.py [+] 4,119-120 All "huawei.248.py" 11L, 453C written [root@bogon good]# python huawei.248.py Traceback (most recent call last): File "huawei.248.py", line 5, in <module> net_connect = ConnectHandler(**huawei) File "/usr/lib/python2.7/site-packages/netmiko/ssh_dispatcher.py", line 246, in ConnectHandler return ConnectionClass(*args, **kwargs) File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 317, in __init__ self._open() File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 322, in _open self.establish_connection() File "/usr/lib/python2.7/site-packages/netmiko/base_connection.py", line 884, in establish_connection self.remote_conn_pre.connect(**ssh_connect_params) File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 406, in connect t.start_client(timeout=timeout) File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 660, in start_client raise e paramiko.ssh_exception.SSHException: Error reading SSH protocol banner‘utf8‘ codec can‘t decode byte 0xff in position 0: invalid start byte
NetMikoTimeoutException: Timed-out reading channel, data not available