- 论坛徽章:
- 0
|
使用paramiko模块的sftp功能,get小文件没有问题,但是一遇到大文件,就报下面的错误:
File "/home/pf/package_get.py", line 16, in sftp_get
sftp.get(src,des)
File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 614, in get
File "build/bdist.linux-x86_64/egg/paramiko/file.py", line 153, in read
File "build/bdist.linux-x86_64/egg/paramiko/sftp_file.py", line 152, in _read
File "build/bdist.linux-x86_64/egg/paramiko/sftp_file.py", line 132, in _read_prefetch
File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 667, in _read_response
paramiko.SSHException: Server connection dropped:
package_get.py代码如下:
#!/bin/env python
"""
You can also use this module for other sftp tasks.
Usage:
import package_get
package_get.sftp_get(host_ip,remote_path,local_path,username,password)
"""
import paramiko
def sftp_get(host_ip,remote_path,local_path,username,password):
t = paramiko.Transport((host_ip,22))
t.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(t)
src = remote_path
des = local_path
sftp.get(src,des)
t.close()
if __name__ == '__main__':
sftp_get("192.168.1.22","/var/tmp/spatch.log","/home/pf/spatch.log","xxxx","xxxx")
我感觉有可能是超时的问题,请问该怎么设置paramiko,或者说服务器端呢? |
|