Periodically get SSH Protocol Error
See original GitHub issueWhen attempting to connect to a Cisco IOS device, I am almost always getting the error listed below, and every now and then it will just work. It is exactly the same issue as #883 however changing global_delay_factor
nor blocking_timeout
seems to change the consistency of being able to connect.
An interesting note, once I connect once I seem to be able to connect repeatedly without issue. Another not that I’m unsure if it is relevant or not, I am using a tunnel to connect:
sshtunnel -v -L 0.0.0.0:10022 -R endhost:22 -U jumphostusername -P jumphostpassword jumphost
And connecting with:
ConnectHandler(device_type="cisco_ios", ip="127.0.0.1", port=10022, username="endhostusername", password="endhostpassword", secret="secret", timeout=30, global_delay_factor=3)
Traceback:
Traceback (most recent call last):
File ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 2138, in _check_banner
buf = self.packetizer.readline(timeout)
File ".../.python/lib/python3.6/site-packages/paramiko/packet.py", line 370, in readline
buf += self._read_timeout(timeout)
File ".../.python/lib/python3.6/site-packages/paramiko/packet.py", line 568, in _read_timeout
raise EOFError()
EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 1966, in run
self._check_banner()
File ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 2143, 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 ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 2138, in _check_banner
buf = self.packetizer.readline(timeout)
File ".../.python/lib/python3.6/site-packages/paramiko/packet.py", line 370, in readline
buf += self._read_timeout(timeout)
File ".../.python/lib/python3.6/site-packages/paramiko/packet.py", line 568, in _read_timeout
raise EOFError()
EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../.python/lib/python3.6/site-packages/netmiko/ssh_dispatcher.py", line 228, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File ".../.python/lib/python3.6/site-packages/netmiko/base_connection.py", line 312, in __init__
self.establish_connection()
File ".../.python/lib/python3.6/site-packages/netmiko/base_connection.py", line 858, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File ".../.python/lib/python3.6/site-packages/paramiko/client.py", line 397, in connect
t.start_client(timeout=timeout)
File ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 587, in start_client
raise e
File ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 1966, in run
self._check_banner()
File ".../.python/lib/python3.6/site-packages/paramiko/transport.py", line 2143, in _check_banner
"Error reading SSH protocol banner" + str(e)
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
Since it seems to be failing here: https://github.com/paramiko/paramiko/blob/master/paramiko/packet.py#L561
I have attempted to print x and when it fails it’s, of course, empty bytes…when it succeeds it reads b'SSH-2.0-Cisco-1.25\n'
I don’t know if it helps or not, but it’s the farthest I can think of to troubleshoot since I’m not sure why this is happening.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
I have seen this happen a lot when testing against Linux Docker containers if I connect too soon after I booting them up. I put a workaround in my code to recognize it and try again.
Added support for banner_timeout argument to the develop branch in Netmiko:
https://github.com/ktbyers/netmiko/pull/1264
Please test and see if increasing this helps. I also set the default banner_timeout to 5 seconds which is greater than the Paramiko uses (paramiko uses 2 seconds by default).
If you are still seeing an issue re-open this issue.