Why i am getting "Paramiko : Error reading SSH protocol banner" in below code? What is the solution for it?

14.7k views Asked by At

I have function in python,(Assume that i have imported all necessary module),

This function is actually a thread,

 def DL_Iperf(args):
        ssh=paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(server_ip,username="root",password=Password)
some_code

This function is actually a thread and it will be created as many no of UE i have, (Ex: if i have 1 UE than 1 Thread will be created),

So, if i have 1 UE/ 2 UE than its working but if i have 3 UE then it is failing, with error "Paramiko : Error reading SSH protocol banner",

Below is the stderr of the script,

No handlers could be found for logger "paramiko.transport"

Unhandled exception in thread started by <function DL_Iperf at 0x02B8ACF0>
Traceback (most recent call last):

File "C:\Users\qxdm-5\Desktop\Chirag\LTE_11_Perfect_Working\TCP_Latest_2\Windo
ws_UE\slave.py", line 379, in DL_Iperf

ssh.connect(ServerIp,username="root",password=Pwd)

File "build\bdist.win32\egg\paramiko\client.py", line 295, in connect

File "build\bdist.win32\egg\paramiko\transport.py", line 451, in start_client

paramiko.SSHException: Error reading SSH protocol banner

From some reference i found that this is because of some network related issue, but my question is if it network related then why everytime in 3rd call of the function i am getting this error? And how do i resolve it?

2

There are 2 answers

0
Martin Prikryl On

I'd guess that the server does not allow (or has problems with opening) three parallel connections from the same client.

Try if you can open three parallel connections using a regular SSH client.

0
Jason On

It is not necessarily a network issue. It could be possible that your system may become low in resources after you've created #1 & #2 and then processes the SSH protocol banner slowly (or past the timeout.)

You can adjust the banner_timeout to test this theory.

Search on "banner_timeout" at: http://docs.paramiko.org/en/1.16/api/client.html