Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using a sample Python script that performs an SSH connection to a switch. However, I'm getting a Traceback error that I cannot root cause.

Traceback issues:

python3 telnet2.py

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 609, in _read_timeout
raise EOFError()
EOFError

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

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 609, in _read_timeout
raise EOFError()
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "telnet2.py", line 12, in <module>
net_connect = ConnectHandler(**CSR)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/netmiko/ssh_dispatcher.py", line 326, in ConnectHandler
return ConnectionClass(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/netmiko/cisco/cisco_ios.py", line 17, in __init__
return super().__init__(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/netmiko/base_connection.py", line 350, in __init__
self._open()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/netmiko/base_connection.py", line 355, in _open
self.establish_connection()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/netmiko/base_connection.py", line 935, in establish_connection
self.remote_conn_pre.connect(**ssh_connect_params)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/client.py", line 406, in connect
t.start_client(timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/paramiko/transport.py", line 660, in start_client
raise e
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

What I have tried:

My code:

from netmiko import ConnectHandler

#First create the device object using a dictionary
CSR = {
    'device_type': 'cisco_ios',
    'ip': '192.168.0.123',
    'username': 'cisco',
    'password': 'cisco'
}

# Next establish the SSH connection
net_connect = ConnectHandler(**CSR)

# Then send the command and print the output
output = net_connect.send_command('show ip int brief')
print (output)

# Finally close the connection
net_connect.disconnect()
Posted
Comments
Richard MacCutchan 9-Oct-21 4:21am    
The messages suggest that the the remote device is not responding in a timely manner, or possibly not responding at all.
wifinut 9-Oct-21 13:15pm    
Thank you. The remote device is active because I can SSH into it manually. I checked this issue other places and the suggestion is to change the banner timeout value. I tried placing the following in my code:

'banner_timeout': 20


after the 'password': 'cisco' statement, but I got the same error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900