1

I am trying to transfer CSV file from one server to another using Paramiko, SSH connection.

I never had any issues with all transfers, but for some random files, I have that:

SSHException: Error reading SSH protocol banner

This is strange because it happens randomly on any file, given that size of the file is almost same. Is there any way to fix it?

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(**self.config, timeout=10, banner_timeout=60)`

after that,

sftp = ssh.open_sftp()
sftp.put(local_path, remote_path)
sftp.close()
ssh.close()
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

0

"Error reading SSH protocol banner" happens while connecting. It should not have anything to do with any specific file. It's rather that the server rejects the connection randomly.

Aren't you connecting too frequently? From the wording of your question, it looks like you are opening a new connection for every file. Consider reusing the connecting for all transfers.

Or the server (or your network) is simply not reliable. If that's so, you will have to code a retry mechanism.

See also Paramiko : Error reading SSH protocol banner

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992