paramiko.ssh_exception.SSHException: Error reading SSH protocol banner when the router is down via SSH tunnel
See original GitHub issueHi,
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:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
just saw your answer. I’ll try something different.
Thanks!
I am going to close as I don’t think there is anything else to do here.