Reputation: 21118
Is there a way to use Paramiko, to connect to sharefile.com as SFTP?
For example using this approach, I can connect to SFTP (the one I created myself in Linux):
from paramiko import SSHConfig, SSHClient, AutoAddPolicy, AuthenticationException
def connect(self):
for rec in self:
with closing(SSHClient()) as ssh:
ssh.set_missing_host_key_policy(AutoAddPolicy())
try:
login = rec.login_id
ssh.connect(login.host, port=login.port, username=login.user, password=login.passwd)
except socket.gaierror:
raise ValidationError(_("Name or service '%s' not known") % (login.host))
except AuthenticationException:
raise Warning(_("Bad username or password"))
with closing(ssh.open_sftp()) as sftp:
#do something
But If I try to connect using login info for fileshare.com, it does not work. In fileshare.com it says you can connect two ways:
Security: Standard (Port 21) or Implicit SSL/TLS (Port 990)
FTP Server: company.sharefileftp.com
User name: username or username_id
Password: (your ShareFile password)
So If I try to connect using port 990, I will get either Connection timed out (after some time) or this error:
File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 306, in connect
t.start_client()
File "/usr/lib/python2.7/dist-packages/paramiko/transport.py", line 465, in start_client
raise e
SSHException: Error reading SSH protocol banner
The only way I was able to connect to it, was using Ubuntu built in GUI to connect so FTP, using:
ftp//:[email protected]
If I used sftp
, it would not connect (I guess it uses default port 22)
I also tried to connect from terminal:
ftp [email protected]
Name or service not known
sftp -oPort=990 [email protected]
ssh_exchange_identification: Connection closed by remote host
Couldn't read packet: Connection reset by peer
Upvotes: 1
Views: 6268
Reputation: 202272
The Secure FTP (FTP over TLS/SSL) is not the SFTP.
The SFTP runs over SSH.
You cannot use Paramiko to connect to the FTP, neither a plain FTP nor over the TLS/SSL.
Use the FTP_TLS
class from the ftplib for FTP over TLS/SSL in Python.
Upvotes: 4