I'm trying to connect to am SFTP server through Paramiko. I don't have a host key. The following code is my attempt and it's giving me an error that says:
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner
I notice that port is usually 22 in other given examples, but the SFTP port I was given is 21. And when I tried 22, it gave me another error saying
Unable to connect to port 22
Thank you in advance for your guidance and insight. Please let me know if I could provide more information.
from paramiko.client import SSHClient
from paramiko import AutoAddPolicy
client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(hostname="a_private_ip",
port=21,
username="user",
password="xxx")
sftp_handle = client.open_sftp()
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.