Paramiko : Error reading SSH protocol banner
It depends on what you mean by "fix". The underlying cause, as pointed out in the comments, are congestion/lack of resources. In that way, it's similar to some HTTP codes. That's the normal cause, it could be that the ssh server is returning the wrong header data.
429 Too Many Requests, tells the client to use rate limiting, or sometimes APIs will return 503 in a similar way, if you exceed your quota. The idea being, to try again later, with a delay.
You can attempt to handle this exception in your code, wait a little while, and try again. You can also edit your transport.py file, to set the banner timeout to something higher. If you have an application where it doesn't matter how quickly the server responds, you could set this to 60 seconds.
EDIT:
Editing your transport file is no longer needed
as per Greg's answer. When you call connect, you can pass a banner_timeout (which solves this issue), a timeout (for the underlying TCP), and an auth_timeout (waiting for authentication response). Greg's answer has a code example with banner_timeout that you can directly lift.
paramiko.SSHException: Error reading SSH protocol banner
That error is generated when paramiko doesn't receive a protocol banner, or the server sends something invalid. If the server is otherwise working correctly, this may be due to some network restrictions.
You can use -vvv
as an option to the openssh client to get more information about how it's connecting, and you can get the actual banner easily using netcat or telnet on port 22. The banner should start with 'SSH-', or paramiko will return the above error immediately.
Error reading SSH protocol banner when connecting to port 443 with Paramiko in Python
You are using WebDAV with WinSCP.
That has nothing to do with SFTP, Paramiko nor any symbols in any banner.
If your server supports WebDAV only, you have to use a WebDAV library or client in your Python code.
Though as you claim that sftp
works, your server seems to support SFTP too. So just connect to the standard SSH/SFTP port 22.
Paramiko Error: Error reading SSH protocol banner
This issue didn't lie with Paramiko, Fabric or the SSH daemon. It was simply a firewall configuration in ISPs internal network. For some reason, they don't allow communication between different subnets of theirs.
We couldn't really fix the firewall configuration so instead we switched all our IPs to be on the same subnet.
Connecting to port 21 with Paramiko and got paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
Paramiko is an SFTP client. The SFTP uses port 22.
If you were given port 21, then it's most likely NOT SFTP. The port 21 is used by FTP. Encrypted variant of FTP, called also FTPS, uses 21 too. And people sometimes mistake it for SFTP.
For FTP use FTP
class from ftplib. For FTPS use FTP_TLS
class from ftplib.
Related Topics
Oserror: [Error 1] Operation Not Permitted
Matplotlib-Animation "No Moviewriters Available"
How to Retrieve the Process Start Time (Or Uptime) in Python
Setting Ld_Library_Path from Inside Python
How to Make Python Script Press 'Enter' When Prompted on Shell
What Conditions Result in an Opened, Nonblocking Named Pipe (Fifo) Being "Unavailable" for Reads
Python: What Are the Nearest Linux and Osx Equivalents of Winsound.Beep
Groupby Weighted Average and Sum in Pandas Dataframe
How to Setup Environment Variable R_User to Use Rpy2 in Python
What Are Python Pandas Equivalents for R Functions Like Str(), Summary(), and Head()
Why Xgrabkey Generates Extra Focus-Out and Focus-In Events