Hello, Dear Developers,
In the last several days I have got the following error:
SSHException: Error reading SSH protocol banner[Errno 104] Connection reset by peer
The interesting thing is that I haven't done any changes to a python script, haven't updated paramiko package and no changes were made to the company server. Another interesting thing is that it works on my local Windows PC.
Bringing some details...
I have a simple Ubuntu 14.04.4 server and a simple backup script which is scheduled via cron (once per week) and which uploads several .zip archives to the company server.
But the last backup was failed because of the error above. The error appears on the step of making a Transport. Here is the piece of code:
`
config = configuration.BackupSystemConfiguration()
host = config.host
port = config.port
transport = paramiko.Transport((host, port)) # <- error is raised here`
I have enabled logging using
import logging
logging.basicConfig(level=logging.DEBUG)
And it shows me the following:
DEBUG:paramiko.transport:starting thread (client mode): 0xf37e9b50L
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.4.1
ERROR:paramiko.transport:Exception: Error reading SSH protocol banner[Errno 104] Connection reset by peer
ERROR:paramiko.transport:Traceback (most recent call last):
ERROR:paramiko.transport: File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 1893, in run
ERROR:paramiko.transport: self._check_banner()
ERROR:paramiko.transport: File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 2049, in _check_banner
ERROR:paramiko.transport: 'Error reading SSH protocol banner' + str(e)
ERROR:paramiko.transport:SSHException: Error reading SSH protocol banner[Errno 104] Connection reset by peer
ERROR:paramiko.transport:
Again, when I try to execute this script on my local Windows PC with the same version of paramiko (2.4.1) I have no errors — everything works flawlessly.
I will be very thankfull for any advice and help. And excuse me for any mistakes — English is not my native language.
Regards,
John.
I also have this problem.
Facing similar problem. Is there a workaround or solution to this?
I've the same problem,confused
This is a catch-all type problem. If the ssh server does not like the connection for one of many different reasons, it disconnects, and this happens.
I have the same problem. Is there a solution for this?
我也是这样的~~
I am also running into this same problem. Is there a solution or workaround for this?
Anybody fixed this already? Same issue,Help me out please!
Check /etc/hosts.deny and /etc/hosts.allow
https://edoceo.com/notabene/ssh-exchange-identification
Is there any solution for this or do we know why it is happening? and how can we avoid such error
Thanks,
Nixit
Looks like the expected behaviour of the SSH server. It prevents unauthenticated connections from queuing up uncontrollably by randomly rejecting them: https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Load_Balancing
This issue can be solved either by boosting MaxStartups on the server side, or by retrying connection on the client multiple times (with random delays).
It would be nice to have a built-in retrier in paramiko, though.
When changing the timeout value (as TinBane mentioned) in the transport.py file from 15 to higher the issue resolved partially. that is at line #484:
self.banner_timeout = 200 # It was 15
However, to resolve it permanently I added a static line to transport.py to declare the new higher value at the _check_banner(self): function.
Here is specifically the change:
``` def _check_banner(self):
for i in range(100):
if i == 0:
timeout = self.banner_timeout
else:
timeout = 2
- After the permanent change became like this:
``` def _check_banner(self):
for i in range(100):
if i == 0:
timeout = self.banner_timeout
timeout = 200 # <<<< Here is the explicit declaration
else:
timeout = 2
When changing the timeout value (as TinBane mentioned) in the transport.py file from 15 to higher the issue resolved partially. that is at line #484:
self.banner_timeout = 200 # It was 15However, to resolve it permanently I added a static line to transport.py to declare the new higher value at the
_check_banner(self):function.Here is specifically the change:
* It was like this:for i in range(100): if i == 0: timeout = self.banner_timeout else: timeout = 2* After the permanent change became like this:for i in range(100): if i == 0: timeout = self.banner_timeout timeout = 200 # <<<< Here is the explicit declaration else: timeout = 2
Thanks you this worked for me!
I tried the same thing, to set timeout to 200, but still getting the same error.
Hello all,
I am not sure anyone can check this out.
I still have the same issue after I modified configuration as below.
def _check_banner(self):
# this is slow, but we only have to do it once
for i in range(100):
# give them 15 seconds for the first line, then just 2 seconds
# each additional line. (some sites have very high latency.)
if i == 0:
timeout = self.banner_timeout
timeout = 200
else:
timeout = 2
My circumstance is that I created this script for maintenance for up to 100 brocade switches through VPN.
I think of course network environment would be able to affect this issue.
Could anyone give me any advice please?
Many thanks!!
Most helpful comment
Looks like the expected behaviour of the SSH server. It prevents unauthenticated connections from queuing up uncontrollably by randomly rejecting them: https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Load_Balancing
This issue can be solved either by boosting MaxStartups on the server side, or by retrying connection on the client multiple times (with random delays).
It would be nice to have a built-in retrier in paramiko, though.