paramiko / paramiko/paramiko

_check_banner timeout for subsequent lines

Open
#2,105 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Exception handling Feature request eval needed
Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Hello,

I am doing ssh over ssm, and while I can set the banner_timeout for the first line, the subsequent lines still fail unless I increase the timeout there. The error I get below has been discussed many times, but I am able to fix it only if I overwrite the timeout in the else clause of the _check_banner method here: https://github.com/paramiko/paramiko/blob/main/paramiko/transport.py#L2269

Why doesn't the else clause also respect the banner timeout?

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 2139, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/packet.py", line 367, in readline
    buf += self._read_timeout(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/packet.py", line 577, in _read_timeout
    raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 1966, in run
    self._check_banner()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 2144, 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 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 2139, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/packet.py", line 367, in readline
    buf += self._read_timeout(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/packet.py", line 577, in _read_timeout
    raise socket.timeout()
socket.timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/fab", line 10, in <module>
    sys.exit(program.run())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/invoke/program.py", line 363, in run
    self.execute()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/invoke/program.py", line 532, in execute
    executor.execute(*self.tasks)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/invoke/executor.py", line 129, in execute
    result = call.task(*args, **call.kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/invoke/tasks.py", line 128, in __call__
    result = self.body(*args, **kwargs)
  File "/Users/matt/work/leo-radar/deploy/fabfile.py", line 158, in test
    ctx.run('printenv | grep HOSTNAME')
  File "<decorator-gen-3>", line 2, in run
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fabric/connection.py", line 29, in opens
    self.open()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fabric/connection.py", line 615, in open
    self.client.connect(**kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/client.py", line 397, in connect
    t.start_client(timeout=timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 587, in start_client
    raise e
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 1966, in run
    self._check_banner()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/paramiko/transport.py", line 2144, in _check_banner
    "Error reading SSH protocol banner" + str(e)
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in paramiko/transport.py at the _check_banner method and inspect how the timeout is passed for the first and subsequent banner lines, focusing on the else clause linked in the issue. Confirm the intended banner_timeout behavior for delayed subsequent lines and add coverage using the repository’s existing test structure. Done means subsequent lines no longer fail when they require the configured banner timeout.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.