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.

Error reading SSH protocol banner

See original GitHub issue

I’m hoping someone here can guide me in the right direction to solve a looping error.

I have some python:

for name in instanceNames:
    print(f'\nChecking {name} ...')
    c = Connection(name)
        try:
            print('Exec hostname')
            r = c.run('hostname', warn=True)
            print(f'{r}')
        except:
            print('SSH session error')

Runs along fine until it hits a particular system and then:

Exception: Error reading SSH protocol banner
Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/paramiko/transport.py", line 2211, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/root/.local/lib/python3.7/site-packages/paramiko/packet.py", line 380, in readline
    buf += self._read_timeout(timeout)
  File "/root/.local/lib/python3.7/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 "/root/.local/lib/python3.7/site-packages/paramiko/transport.py", line 2039, in run
    self._check_banner()
  File "/root/.local/lib/python3.7/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

Exception: Error reading SSH protocol banner
Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/paramiko/transport.py", line 2211, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/root/.local/lib/python3.7/site-packages/paramiko/packet.py", line 380, in readline
    buf += self._read_timeout(timeout)
  File "/root/.local/lib/python3.7/site-packages/paramiko/packet.py", line 622, in _read_timeout
    raise socket.timeout()
_socket.timeout

During handling of the above exception, another exception occurred:
...

This goes on until I CTRL-C, after which all other host items throw an exception.

I don’t really care at the moment about the banner exception on that particular host (I will deal with that later) but for now I’d like to avoid the retries and subsequent failures. Any tips?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
davidjmemmettcommented, Mar 31, 2021

Hi @Gary-Armstrong,

It looks like it might be worth passing banner_timeout to Connection.connect_kwargs and seeing if that helps.

A quick example (untested):

c = Connection(
    host="hostname",
    user="username",
    connect_kwargs={
        "banner_timeout": 60,
    },
)

A couple of people appear to have had a similar issue to yours before, and adding a reasonable banner_timeout appears to have helped. Let me know how you get on!

Cheers, David

0reactions
npfosscommented, Oct 26, 2022

In case this helps anyone like me who wasn’t creating a Connection manually, it was just through the magic of fabric:

you can create a fabric.yml with a bunch of config settings including banner_timeout, and put it in the dir you’re calling fab from, e.g.

connect_kwargs:
    banner_timeout: 60

and you can confirm that the settings are being used by adding this in your imports to turn on paramiko debug logging:

import logging
logging.basicConfig(level=logging.DEBUG)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Paramiko : Error reading SSH protocol banner - Stack Overflow
It could be network congestion, faulty switches, etc... but usually it means that the target server is bogged down or its sshd has...
Read more >
Message: Error Reading SSH Protocol Banner
Message: Error Reading SSH Protocol Banner ... Nodegrid allows 10 ssh connections enqueued during protocol negotiation phase. So if you launch more than...
Read more >
Error reading SSH protocol banner[Errno 104] Connection ...
I'm working on a CircleCi job running a configuration on an EC2 instance. The problem is that the ansible could not run the...
Read more >
Error reading SSH protocol banner - Google Groups
If that doesn't work, the specific error you're looking at, "error reading ssh protocol banner", sounds more like you're ending up on the...
Read more >
Bug #14500: "Error reading SSH protocol banner" in rados ...
This was due to conflicting entries for the machines in my known_hosts file and once they were removed the operation succeeded. After my...
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