Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用PySFP进行键盘交互身份验证的EOFError_Python_Sftp_Paramiko_Pysftp - Fatal编程技术网

Python 使用PySFP进行键盘交互身份验证的EOFError

Python 使用PySFP进行键盘交互身份验证的EOFError,python,sftp,paramiko,pysftp,Python,Sftp,Paramiko,Pysftp,我正在尝试从SFTP服务器下载一些文件。我使用以下代码: keydata = b"""AAAAB3Nza.............CNpvoUP7p""" key = paramiko.RSAKey(data=decodebytes(keydata)) cnopts = pysftp.CnOpts() cnopts.hostkeys.add(host, 'ssh-rsa', key) host = 'sftp.foo.com' user

我正在尝试从SFTP服务器下载一些文件。我使用以下代码:

keydata = b"""AAAAB3Nza.............CNpvoUP7p"""
key = paramiko.RSAKey(data=decodebytes(keydata))
cnopts = pysftp.CnOpts()
cnopts.hostkeys.add(host, 'ssh-rsa', key)
host = 'sftp.foo.com'
username = 'test'
password = 'test'

with pysftp.Connection(host=host, username=username, password=password, cnopts=cnopts) as sftp:
    sftp.listdir()
    .....
但我得到了以下错误:

引发异常:
回溯(最近一次呼叫最后一次):
文件“/home/myuser/src/ftp data/ftp_data/downloader_v2.py”,第25行,在main中
sftp.listdir()
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/pysftp/_init__.py”,第591行,在listdir中
self._sftp_connect()
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/pysftp/__init__.py”,第205行,在_sftp_connect中
self.\u sftp=paramiko.SFTPClient.from_transport(self.\u transport)
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/paramiko/sftp_client.py”,第165行,from_transport
窗口大小=窗口大小,最大数据包大小=最大数据包大小
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/paramiko/transport.py”,第879行,打开会话
超时=超时,
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/paramiko/transport.py”,第1006行,开放频道
提高e
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/paramiko/transport.py”,第2055行,运行中
ptype,m=self.packetizer.read_message()
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/paramiko/packet.py”,第459行,在read_消息中
header=self.read\u all(self.\u块大小\u in,check\u rekey=True)
文件“/home/myuser/environments/python3.5.2_ubuntu16.04/lib/python3.5/site packages/paramiko/packet.py”,第303行,全部读取
提高EOR()
伊奥费罗
我尝试过的其他SFTP主机也可以正确使用相同的代码。我还可以使用
sftp
命令行(Ubuntu)正确下载这些文件

这是我的Paramiko日志:

DEB[20201029-09:30:00.939]thr=1 paramiko.transport:启动线程(客户端模式):0xd5ac908
DEB[20201029-09:30:00.940]thr=1 paramiko.transport:本地版本/idstring:SSH-2.0-paramiko_2.7.2
DEB[20201029-09:30:01.029]thr=1 paramiko.transport:Remote version/idstring:SSH-2.0-Server
INF[20201029-09:30:01.030]thr=1 paramiko.transport:已连接(版本2.0,客户端-服务器)
DEB[20201029-09:30:01.121]thr=1 paramiko.transport:kex-algos:['ecdh-sha2-nistp521','ecdh-sha2-nistp384','ecdh-sha2-nistp256','diffie-hellman-group-exchange-sha256','diffie-hellman-group-exchange-sha1','diffie-hellman-group18-sha512','diffie-hellman-group17-sha512','diffie-hellman-group16-sha512','diffie-hellman-group15-sha512','diffie-hellman-group14-sha256','diffie-hellman-hellman-group14-sha1','-hellman-group1-sha1']服务器密钥:['ecdsa-sha2-nistp256','ssh rsa']客户端加密:['blowfish-cbc','aes128 ctr','aes192 ctr','aes256 ctr','arcfour256','arcfour128','aes128 cbc','3des cbc','aes192 cbc','aes256 cbc']服务器加密:['blowfish-cbc','aes128 ctr','aes192 ctr','aes256 ctr','arcfour256','arcfour128','aes128 cbc','3des cbc','aes192 cbc','aes256 cbc']客户端mac:['hmac-md5','hmac-sha1','hmac-sha2-256','hmac-sha2-512','hmac-sha1-96','hmac-md5-96']服务器mac:['hmac-md5','hmac-sha1','hmac-sha2-256','hmac-sha2-512','hmac-sha1-96']客户端压缩:['none']服务器压缩:['none']客户端语言:['']服务器语言:[''kex如下?False
DEB[20201029-09:30:01.121]thr=1 paramiko.运输:Kex同意:ecdh-sha2-nistp256
DEB[20201029-09:30:01.121]thr=1 paramiko.transport:HostKey约定:ecdsa-sha2-nistp256
DEB[20201029-09:30:01.121]thr=1 paramiko.运输:同意密码:aes128中心
DEB[20201029-09:30:01.121]thr=1 paramiko.运输:MAC同意:hmac-sha2-256
DEB[20201029-09:30:01.121]thr=1 paramiko.运输:同意压缩:无
DEB[20201029-09:30:01.217]thr=1 paramiko.transport:kex引擎KexNistp256指定哈希算法
DEB[20201029-09:30:01.307]thr=1 paramiko.transport:切换到新键。。。
DEB[20201029-09:30:01.309]thr=2 paramiko.transport:主机密钥已验证(ecdsa-sha2-nistp256)
DEB[20201029-09:30:01.309]thr=2 paramiko.transport:正在尝试密码验证。。。
DEB[20201029-09:30:01.400]thr=1 paramiko.transport:userauth正常
INF[20201029-09:30:01.771]thr=1 paramiko.transport:身份验证继续。。。
DEB[20201029-09:30:01.772]thr=1 paramiko.transport:Methods:['keyboard-interactive']
DEB[20201029-09:30:01.772]thr=2 paramiko.transport:[chan 0]最大数据包长度:32768字节
DEB[20201029-09:30:01.864]thr=1 paramiko.transport:传输线程中的EOF
这里是my
sftp-vv的输出:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.8,OpenSSL 1.0.2g 2016年3月1日
debug1:读取配置数据/etc/ssh/ssh\u config
debug1:/etc/ssh/ssh\u配置第19行:应用*
debug2:解析“sftp.foo.com”端口22
debug2:ssh\u connect\u direct:needpriv 0
debug1:连接到sftp.foo.com[52.xx.xx.xx]端口22。
debug1:已建立连接。
debug1:identity file/home/myuser/.ssh/id\u rsa类型1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id\u rsa-cert类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id_dsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id_dsa-cert type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id_ecdsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id_ecdsa-cert type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id_ed25519 type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/home/myuser/.ssh/id_ed25519-cert type-1
debug1:为启用兼容模式