Closed pavankandukuri closed 5 years ago
Try setting banner_timeout argument to 30. This is an argument to connecthandler.
Kirk
On Mon, Aug 19, 2019 at 3:28 AM pavankandukuri notifications@github.com wrote:
Greetings Everyone,
I have run into a very peculiar issue. I wrote a small python program (well I am rookie) to login to network devices (used the device type autodetect) and run show commands and fetch the data into a text (.txt) file. It was running fine until my laptop had to be rebuild due to companies policies and was upgraded to windows 10. After the upgrade, the program was not able to SSH into cisco wlc devices and started throwing the below mentioned error. Please do note that the program is able to run fine and SSH into other device types (cisco and juniper). To troubleshoot the issue I have changed the devicetype to cisco_wlc, cisco_wlc_ssh which yielded no result. I have increased the banner timeout in def _check_banner(self): to 60 seconds and beyond with no luck. I have also used the global_delay_factor uptill 10 but in vain. Cannot isolate the issue to windows 10 because ssh to cisco ios devices is working fine using the exact code with devicetype as autodetect as well as cisco_ios and the code for cisco_wlc works fine when run from windows 7 laptop. Any help in resolving this issue is greatly appreciated!!
netmiko.version '2.4.1' paramiko.version '2.6.0'
The code for SSH into a device: cisco={'device_type':'cisco_wlc_ssh','host':ip_address,'username':'***','password':'****'} def WLCLOGIN(ip_address): print ('in function') commands=['show wlan 20'] output='' print ('logging into device') wlc_ssh=nk.ConnectHandler(**cisco) print ('logged into device') for cmd in commands: output1=wlc_ssh.send_command(cmd) output=output+output1 with open (str(ip_address)+'_wlcconfig.txt', 'w') as file: file.write(output) print ('file write') file_name.append(str(ip_address)+'_wlcconfig.txt') Error message thrown:
Exception: Error reading SSH protocol banner Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2211, in _check_banner buf = self.packetizer.readline(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 380, in readline buf += self._read_timeout(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 622, in _read_timeout raise socket.timeout() socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2039, in run self._check_banner() File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2216, in _check_banner "Error reading SSH protocol banner" + str(e) paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2211, in _check_banner buf = self.packetizer.readline(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 380, in readline buf += self._read_timeout(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 622, in _read_timeout raise socket.timeout() socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program Files\Python37\Lib\site-packages\Hackathon\Hackathon code\8021x_reqd.py", line 57, in WLCLOGIN(ip_address) File "C:\Program Files\Python37\Lib\site-packages\Hackathon\Hackathon code\8021x_reqd.py", line 11, in WLCLOGIN wlc_ssh=nk.ConnectHandler(*cisco) File "C:\Program Files\Python37\lib\site-packages\netmiko\ssh_dispatcher.py", line 243, in ConnectHandler return ConnectionClass(args, kwargs) File "C:\Program Files\Python37\lib\site-packages\netmiko\base_connection.py", line 317, in init self._open() File "C:\Program Files\Python37\lib\site-packages\netmiko\base_connection.py", line 322, in _open self.establish_connection() File "C:\Program Files\Python37\lib\site-packages\netmiko\base_connection.py", line 869, in establish_connection self.remote_conn_pre.connect(ssh_connect_params) File "C:\Program Files\Python37\lib\site-packages\paramiko\client.py", line 406, in connect t.start_client(timeout=timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 660, in start_client raise e File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2039, in run self._check_banner() File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2216, in _check_banner "Error reading SSH protocol banner" + str(e) paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ktbyers/netmiko/issues/1327?email_source=notifications&email_token=AAG3VBAKXSB552BG72XFKHDQFKNWXA5CNFSM4INBJ522YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HF7QB2Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG3VBGD2GECXG7ASUENP63QFKNWXANCNFSM4INBJ52Q .
-- Kirk Byers ktbyers@twb-tech.com ktbyers@twb-tech.com Simplify through Automation
Thanks a lot for the quick response Kirk, it worked with banner_timeout set at 10. What is confusing to me is that the same code with banner_timeout at default runs fine on a windows7 machine but on a windows10 machine, the same code requires banner_timeout to be set at 10. Wonder what is causing this.
Different openSSH (or whatever windows has) versions or something perhaps? Anyway, glad its working, closing!
Can I get the python3 code for this? trying to get into multiple cisco wlc to automate the image upgrades
Greetings Everyone,
The code for SSH into a device:
cisco={'device_type':'cisco_wlc_ssh','host':ip_address,'username':'***','password':'****'} def WLCLOGIN(ip_address): print ('in function') commands=['show wlan 20'] output='' print ('logging into device') wlc_ssh=nk.ConnectHandler(**cisco) print ('logged into device') for cmd in commands: output1=wlc_ssh.send_command(cmd) output=output+output1 with open (str(ip_address)+'_wlcconfig.txt', 'w') as file: file.write(output) print ('file write') file_name.append(str(ip_address)+'_wlcconfig.txt')
Error message thrown:
Exception: Error reading SSH protocol banner Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2211, in _check_banner buf = self.packetizer.readline(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 380, in readline buf += self._read_timeout(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 622, in _read_timeout raise socket.timeout() socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2039, in run self._check_banner() File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2216, in _check_banner "Error reading SSH protocol banner" + str(e) paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
Traceback (most recent call last): File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2211, in _check_banner buf = self.packetizer.readline(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 380, in readline buf += self._read_timeout(timeout) File "C:\Program Files\Python37\lib\site-packages\paramiko\packet.py", line 622, in _read_timeout raise socket.timeout() socket.timeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Program Files\Python37\Lib\site-packages\Hackathon\Hackathon code\8021x_reqd.py", line 57, in
WLCLOGIN(ip_address)
File "C:\Program Files\Python37\Lib\site-packages\Hackathon\Hackathon code\8021x_reqd.py", line 11, in WLCLOGIN
wlc_ssh=nk.ConnectHandler(*cisco)
File "C:\Program Files\Python37\lib\site-packages\netmiko\ssh_dispatcher.py", line 243, in ConnectHandler
return ConnectionClass(args, kwargs)
File "C:\Program Files\Python37\lib\site-packages\netmiko\base_connection.py", line 317, in init
self._open()
File "C:\Program Files\Python37\lib\site-packages\netmiko\base_connection.py", line 322, in _open
self.establish_connection()
File "C:\Program Files\Python37\lib\site-packages\netmiko\base_connection.py", line 869, in establish_connection
self.remote_conn_pre.connect(ssh_connect_params)
File "C:\Program Files\Python37\lib\site-packages\paramiko\client.py", line 406, in connect
t.start_client(timeout=timeout)
File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 660, in start_client
raise e
File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2039, in run
self._check_banner()
File "C:\Program Files\Python37\lib\site-packages\paramiko\transport.py", line 2216, in _check_banner
"Error reading SSH protocol banner" + str(e)
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner