如何通过sftp Python连接到Droxbox?

时间:2019-04-17 17:31:16

标签: python sftp

我想通过Python从Droxbox发送/下载文件。我已经尝试过pysftpparamiko,但是connect()的呼叫将挂起。下面是我的代码。

import paramiko

# create a client
ssh = paramiko.SSHClient()
# can alos choose .WarningPolicy(), .RejectPolicy()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname="dropbox.com", username="my username", password="my pw")
# The call will hang there

sftp代码

import pysftp as sftp
cnopts = sftp.CnOpts()
cnopts.hostkeys = None

'''If I don't set up cnopts, I'll get error - No hostkey for host dropbox.com found.
But I got a warning if I set up the above cnopts - 
CryptographyDeprecationWarning: Support for unsafe construction of 
public numbers from encoded data will be removed in a future 
version. Please use EllipticCurvePublicKey.from_encoded_point
self.ecdsa_curve.curve_class(), pointinfo
'''
s = sftp.Connection(host="dropbox.com",
                    username="xi@transcriptic.com",                             
                    password="Python@2018",
                    cnopts=cnopts)

任何建议将不胜感激!

1 个答案:

答案 0 :(得分:1)

可悲的是,我不相信Dropbox支持SFTP。