Python 报错处理 paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

使用多进程启动多个ssh报错: 

Exception (client): Error reading SSH protocol banner[Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/anaconda3/envs/Python38/lib/python3.8/site-packages/paramiko/transport.py", line 2091, in run
    self._check_banner()
  File "/root/anaconda3/envs/Python38/lib/python3.8/site-packages/paramiko/transport.py", line 2272, in _check_banner
    raise SSHException(
Traceback (most recent call last):
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner[Errno 104] Connection reset by peer

  File "/root/anaconda3/envs/Python38/lib/python3.8/site-packages/paramiko/transport.py", line 2268, in _check_banner
    buf = self.packetizer.readline(timeout)
  File "/root/anaconda3/envs/Python38/lib/python3.8/site-packages/paramiko/packet.py", line 374, in readline
    buf += self._read_timeout(timeout)
  File "/root/anaconda3/envs/Python38/lib/python3.8/site-packages/paramiko/packet.py", line 601, in _read_timeout
    x = self.__socket.recv(128)
ConnectionResetError: [Errno 104] Connection reset by peer

其中一种可能原因是目标Linux系统的ssh连接数有限制,可尝试修改ssh连接数后重启ssh:

vim /etc/ssh/sshd_config

Python 报错处理 paramiko.ssh_exception.SSHException: Error reading SSH protocol banner_第1张图片

 MaxStartups参数可以设置最大未认证连接数。默认设置是 10:30:100,意思是从第10个连接开始以30%的概率拒绝新连接,直到连接数达到100为止。

# Ubuntu系统
/etc/init.d/ssh restart

# Centos系统
service sshd restart

你可能感兴趣的:(Python,Python,paramiko,ssh)