Paramiko获取请求在python中以EOFError()终止

时间:2018-10-18 19:51:54

标签: python sftp paramiko downloading

我正在尝试使用Paramiko的sftp.get函数从服务器下载文件。

我不断收到以下错误代码: Error Code

这是我的Paramiko.log

DEB [20181018-15:39:14.299] thr=1   paramiko.transport: starting 

thread (client mode): 0x3462d30L
DEB [20181018-15:39:14.299] thr=1   paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.4.2
DEB [20181018-15:39:14.438] thr=1   paramiko.transport: Remote version/idstring: SSH-2.0-0
INF [20181018-15:39:14.438] thr=1   paramiko.transport: Connected (version 2.0, client 0)
DEB [20181018-15:39:14.799] thr=1   paramiko.transport: kex algos:[u'diffie-hellman-group1-sha1', u'diffie-hellman-group14-sha1'] server key:[u'ssh-dss', u'ssh-rsa'] client encrypt:[u'3des-cbc', u'blowfish-cbc', u'aes256-cbc', u'aes128-cbc', u'cast128-cbc'] server encrypt:[u'3des-cbc', u'blowfish-cbc', u'aes256-cbc', u'aes128-cbc', u'cast128-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96', u'hmac-md5', u'hmac-md5-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96', u'hmac-md5', u'hmac-md5-96'] client compress:[u'none'] server compress:[u'none'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20181018-15:39:14.799] thr=1   paramiko.transport: Kex agreed: diffie-hellman-group14-sha1
DEB [20181018-15:39:14.799] thr=1   paramiko.transport: HostKey agreed: ssh-rsa
DEB [20181018-15:39:14.799] thr=1   paramiko.transport: Cipher agreed: aes128-cbc
DEB [20181018-15:39:14.799] thr=1   paramiko.transport: MAC agreed: hmac-sha1
DEB [20181018-15:39:14.799] thr=1   paramiko.transport: Compression agreed: none
DEB [20181018-15:39:15.243] thr=1   paramiko.transport: kex engine KexGroup14 specified hash_algo <built-in function openssl_sha1>
DEB [20181018-15:39:15.385] thr=1   paramiko.transport: Switch to new keys ...
DEB [20181018-15:39:15.401] thr=2   paramiko.transport: Attempting password auth...
DEB [20181018-15:39:15.542] thr=1   paramiko.transport: userauth is OK
INF [20181018-15:39:15.684] thr=1   paramiko.transport: Auth banner: 


INF [20181018-15:39:16.029] thr=1   paramiko.transport: Authentication (password) successful!
DEB [20181018-15:39:16.043] thr=2   paramiko.transport: [chan 0] Max packet in: 32768 bytes
DEB [20181018-15:39:16.170] thr=1   paramiko.transport: [chan 0] Max packet out: 30000 bytes
DEB [20181018-15:39:16.170] thr=1   paramiko.transport: Secsh channel 0 opened.
DEB [20181018-15:39:16.358] thr=1   paramiko.transport: [chan 0] Sesch channel 0 request ok
INF [20181018-15:39:16.499] thr=2   paramiko.transport.sftp: [chan 0] Opened sftp connection (server version 3)
DEB [20181018-15:39:16.513] thr=2   paramiko.transport.sftp: [chan 0] listdir('/g_dura_ue_virtual/dura_ue/Qualcomm/Device_SW/SDM845\\Software\\')
DEB [20181018-15:39:30.562] thr=2   paramiko.transport.sftp: [chan 0] stat('/g_dura_ue_virtual/dura_ue/Qualcomm/Device_SW/SDM845/Software/R2.0.115.exe')
DEB [20181018-15:39:30.736] thr=2   paramiko.transport.sftp: [chan 0] open('/g_dura_ue_virtual/dura_ue/Qualcomm/Device_SW/SDM845/Software/R2.0.115.exe', 'rb')
DEB [20181018-15:39:30.892] thr=2   paramiko.transport.sftp: [chan 0] open('/g_dura_ue_virtual/dura_ue/Qualcomm/Device_SW/SDM845/Software/R2.0.115.exe', 'rb') -> 323130
ERR [20181018-15:39:56.565] thr=1   paramiko.transport: Socket exception: An existing connection was forcibly closed by the remote host (10054)
DEB [20181018-15:39:56.565] thr=2   paramiko.transport.sftp: [chan 0] close(323130)
INF [20181018-15:39:56.565] thr=2   paramiko.transport.sftp: [chan 0] sftp session closed.

我已经在以下链接中尝试了解决方案。我的paramiko版本是2.4.2(最新版本)。

paramiko hangs on get after ownloading 20 MB of file

Paramiko sftp put request getting terminated with EOFError() in python

这是我的代码:

transport = paramiko.Transport((host, port))
paramiko.util.log_to_file("paramiko.log")
#<SFTP FIXES>
transport.default_window_size = 2000000000
transport.packetizer.REKEY_BYTES = pow(2, 40)  
transport.packetizer.REKEY_PACKETS = pow(2, 40) 
#</SFTP FIXES>

try: #connecting
    print "\nConnecting to " + host + "\n"
    transport.connect(username = username, password = password)
    sftp = paramiko.SFTPClient.from_transport(transport)
    print "Connection established"
except:
    error("Couldn't connect to " + host)
    quit()

try:
        sftp.get(remote_path + "/Software/" + newest_version , local_path + "\\" + newest_version, callback=printTotals)
except Exception as e:
            print(e)
            cleanup(sftp, transport)
            exit()

0 个答案:

没有答案