我试图通过pysftp发送一些文件,身份验证看起来很好,但实际上将文件结果挂起,什么都不做。文件很小(<200kb),所以我不相信它是一个上传问题(互联网访问很好)。最终连接超时。
代码:
if os.listdir(ftp_path):# only do if files are there
with pysftp.Connection(FTP_SERVER,
port=FTP_PORT
username=FTP_USER,
private_key=FTP_SSH_PRIVATE_KEY_PATH
) as sftp:
with sftp.cd(FTP_REMOTE_FOLDER):
for f in os.listdir(ftp_path):
if os.path.isfile(os.path.join(ftp_path,f)) :
# upload image to server
self.log.info("HB FTP, Start upload: "+f)
print(ftp_path+"\\"+f)
sftp.put(os.path.join(ftp_path,f))
self.log.info("HB FTP, Finished Upload: "+f)
在此处记录输出:
FSW_COMMS paramiko.transport 01/24/2015 04:23:58 PM: INFO: Authentication (publickey) successful!
FSW_COMMS paramiko.transport 01/24/2015 04:23:58 PM: DEBUG: [chan 1] Max packet in: 32768 bytes
FSW_COMMS paramiko.transport 01/24/2015 04:23:58 PM: DEBUG: [chan 1] Max packet out: 0 bytes
FSW_COMMS paramiko.transport 01/24/2015 04:23:58 PM: DEBUG: Secsh channel 1 opened.
FSW_COMMS paramiko.transport 01/24/2015 04:23:58 PM: DEBUG: [chan 1] Sesch channel 1 request ok
FSW_COMMS paramiko.transport.sftp 01/24/2015 04:23:58 PM: INFO: [chan 1] Opened sftp connection (server version 3)
FSW_COMMS paramiko.transport.sftp 01/24/2015 04:23:58 PM: DEBUG: [chan 1] normalize('.')
FSW_COMMS paramiko.transport.sftp 01/24/2015 04:23:58 PM: DEBUG: [chan 1] stat('files')
FSW_COMMS paramiko.transport.sftp 01/24/2015 04:23:58 PM: DEBUG: [chan 1] normalize('files')
FSW_COMMS root 01/24/2015 04:23:58 PM: INFO: HB FTP, Start upload: 2015-01-17-19-37-07.jpg
FSW_COMMS paramiko.transport.sftp 01/24/2015 04:23:58 PM: DEBUG: [chan 1] open('/files/2015-01-17-19-37-07.jpg', 'wb')
FSW_COMMS paramiko.transport.sftp 01/24/2015 04:23:58 PM: DEBUG: [chan 1] open('/files/2015-01-17-19-37-07.jpg', 'wb') -> 34613039393262343666383036653839
有关如何进一步调试的任何帮助或指示,非常感谢,
朱
答案 0 :(得分:0)
这似乎是您正在使用的Paramiko版本中的错误(我怀疑是1.15.1或更早版本):https://lists.nongnu.org/archive/html/duplicity-talk/2015-05/msg00023.html
升级到1.15.4解决了我的问题。