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.

paramiko.ssh_exception.SSHException: Error reading SSH protocol banner when the router is down via SSH tunnel

See original GitHub issue

Hi,

I am connecting to a device via ssh tunnel just fine. During a reload, I am getting the following traceback:

Exception: Error reading SSH protocol banner Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 2211, in _check_banner buf = self.packetizer.readline(timeout) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/packet.py", line 380, in readline buf += self._read_timeout(timeout) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/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 "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 2039, in run self._check_banner() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 2215, in _check_banner raise SSHException( paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

Since it’s part of try/except, the script doesn’t break. I’m having hard time with paramiko “establishing” ssh connection to a device that is down and throwing the stack backtrace. When the router comes up the connection is established just fine. Here is the output of the debug:

DEBUG:paramiko.transport:starting thread (client mode): 0xdd2bb80 DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.7.1 ERROR:paramiko.transport:Exception: Error reading SSH protocol banner ERROR:paramiko.transport:Traceback (most recent call last): ERROR:paramiko.transport: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 2211, in _check_banner ERROR:paramiko.transport: buf = self.packetizer.readline(timeout) ERROR:paramiko.transport: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/packet.py", line 380, in readline ERROR:paramiko.transport: buf += self._read_timeout(timeout) ERROR:paramiko.transport: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/packet.py", line 622, in _read_timeout ERROR:paramiko.transport: raise socket.timeout() ERROR:paramiko.transport:socket.timeout ERROR:paramiko.transport: ERROR:paramiko.transport:During handling of the above exception, another exception occurred: ERROR:paramiko.transport: ERROR:paramiko.transport:Traceback (most recent call last): ERROR:paramiko.transport: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 2039, in run ERROR:paramiko.transport: self._check_banner() ERROR:paramiko.transport: File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 2215, in _check_banner ERROR:paramiko.transport: raise SSHException( ERROR:paramiko.transport:paramiko.ssh_exception.SSHException: Error reading SSH protocol banner ERROR:paramiko.transport: Connect to 9.0.6.202 failed

The code: try: net = ConnectHandler(**lab) print(f"““Connected to {lab[“ip”]}\n””“) prompt = net.find_prompt() except: print(f”““Connect to {lab[“ip”]} failed\n””") exit()

I have followed paramiko’s posts regarding this exception and patched proxy.py and transport.py accordingly, but neither of the cases was referring to a device down case.

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ciscoratcommented, Mar 11, 2020

just saw your answer. I’ll try something different.

Thanks!

0reactions
ktbyerscommented, Mar 12, 2020

I am going to close as I don’t think there is anything else to do here.

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 >
Waiting for SSH service to be ready with Paramiko - NetDevOps
SSHException with a particular message Error reading SSH protocol banner; if the socket is open and SSH service responding on the remote part...
Read more >
Python SSH Client - Paramiko. SSH with Python. - YouTube
In this video, I go over how to create ssh sessions with Paramiko. ‍ Join our Discord Community of DevOps...
Read more >
Python – Paramiko : Error reading SSH protocol banner
Recently, I made a code that connect to work station with different usernames (thanks to a private key) based on paramiko. I never...
Read more >
paramiko.SSHClient Example - Program Talk
SSHException : exit("Error: Couldn't connect to server") except paramiko. ... indicates # SSH protocol banner read failures, assume it's caused by the ...
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