question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Periodically get SSH Protocol Error

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Alan-Rcommented, Jun 24, 2019

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.

0reactions
ktbyerscommented, Jun 29, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common error messages
This error message occurs when PuTTY connects to a new SSH server. Every server identifies itself by means of a host key; once...
Read more >
SSH Protocol error: Server and client capabilities don't match
Since there is no match between both lists, its not possible to connect to the server. Your server wants to exchange keys explicitly...
Read more >
Common error messages - Tartarus
Check that you are connecting with the correct protocol (SSH, Telnet, etc), and check that the port number is correct. If that fails,...
Read more >
How to Troubleshoot SSH Protocol Issues
Problems during SSH protocol initiation include the client suddenly getting dropped or closed, the client returning errors about cipher ...
Read more >
OpenSSH Server connection drops out after inactivity problem
This is usually the result of a packet filter or NAT device timing out your TCP connection due to inactivity. For security, reason...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found