Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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 Paramiko挂起ssh.opensftp()_Python_Ssh_Sftp_Paramiko - Fatal编程技术网

Python Paramiko挂起ssh.opensftp()

Python Paramiko挂起ssh.opensftp(),python,ssh,sftp,paramiko,Python,Ssh,Sftp,Paramiko,我尝试运行以下脚本: import paramiko import os host, port, user, passw, key = .... transport = paramiko.Transport((host, port)) ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) private_key_fil

我尝试运行以下脚本:

import paramiko
import os

host, port, user, passw, key = .... 

transport = paramiko.Transport((host, port))
ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

private_key_file = key
paramiko.util.log_to_file("filename.log")
xSx_key = paramiko.RSAKey.from_private_key_file(private_key_file,None)
transport.connect(username = user, password=passw, pkey = xSx_key)
ssh.connect(host, username=user, password=passw, pkey=xSx_key, port=port) 


ftp = ssh.open_sftp()
files = ftp.listdir()
不幸的是,这在open_sftp()调用期间挂起。如果随后执行键盘中断,则会得到以下堆栈跟踪:

  ftp = ssh.open_sftp()
  File "build\bdist.win-amd64\egg\paramiko\client.py", line 379, in open_sftp
  File "build\bdist.win-amd64\egg\paramiko\transport.py", line 811, in open_sftp_client
  File "build\bdist.win-amd64\egg\paramiko\sftp_client.py", line 128, in from_transport
  File "build\bdist.win-amd64\egg\paramiko\transport.py", line 615, in open_session
  File "build\bdist.win-amd64\egg\paramiko\transport.py", line 726, in open_channel
  File "C:\Anaconda\lib\threading.py", line 620, in wait
    self.__cond.wait(timeout)
  File "C:\Anaconda\lib\threading.py", line 358, in wait
    _sleep(delay)
KeyboardInterrupt
paramiko日志文件显示以下内容:

DEB [20150702-17:22:11.519] thr=1   paramiko.transport: starting thread (client mode): 0x32a00f0L
INF [20150702-17:22:11.604] thr=1   paramiko.transport: Connected (version 2.0, client SSHD)
DEB [20150702-17:22:11.686] thr=1   paramiko.transport: kex algos:[u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1', u'diffie-hellman-group-exchange-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] server encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96'] client compress:[u'none', u'zlib'] server compress:[u'none', u'zlib'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20150702-17:22:11.687] thr=1   paramiko.transport: Ciphers agreed: local=aes128-cbc, remote=aes128-cbc
DEB [20150702-17:22:11.687] thr=1   paramiko.transport: using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-cbc, remote aes128-cbc; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
DEB [20150702-17:22:12.020] thr=1   paramiko.transport: Switch to new keys ...
DEB [20150702-17:22:12.026] thr=2   paramiko.transport: Attempting public-key auth...
DEB [20150702-17:22:12.188] thr=1   paramiko.transport: userauth is OK
INF [20150702-17:22:14.894] thr=1   paramiko.transport: Auth banner: <cut>

INF [20150702-17:22:15.078] thr=1   paramiko.transport: Authentication continues...
DEB [20150702-17:22:15.078] thr=1   paramiko.transport: Methods: [u'password', u'publickey', u'keyboard-interactive']
DEB [20150702-17:22:15.168] thr=3   paramiko.transport: starting thread (client mode): 0x33263c8L
INF [20150702-17:22:15.253] thr=3   paramiko.transport: Connected (version 2.0, client SSHD)
DEB [20150702-17:22:15.335] thr=3   paramiko.transport: kex algos:[u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1', u'diffie-hellman-group-exchange-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] server encrypt:[u'aes256-cbc', u'aes192-cbc', u'aes128-cbc', u'3des-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96'] client compress:[u'none', u'zlib'] server compress:[u'none', u'zlib'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20150702-17:22:15.335] thr=3   paramiko.transport: Ciphers agreed: local=aes128-cbc, remote=aes128-cbc
DEB [20150702-17:22:15.335] thr=3   paramiko.transport: using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-cbc, remote aes128-cbc; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
DEB [20150702-17:22:15.671] thr=3   paramiko.transport: Switch to new keys ...
DEB [20150702-17:22:15.680] thr=2   paramiko.transport: Adding ssh-rsa host key for [<cut>]:<cut>: e5025a02b8ca851f7f0a2d173161400c
DEB [20150702-17:22:15.680] thr=2   paramiko.transport: Trying SSH key 4e85b76b311684e139c597cbab111fef
DEB [20150702-17:22:15.841] thr=3   paramiko.transport: userauth is OK
INF [20150702-17:22:19.246] thr=3   paramiko.transport: Auth banner: <cut>

INF [20150702-17:22:19.426] thr=3   paramiko.transport: Authentication continues...
DEB [20150702-17:22:19.427] thr=3   paramiko.transport: Methods: [u'password', u'publickey', u'keyboard-interactive']
DEB [20150702-17:22:19.438] thr=2   paramiko.transport: [chan 0] Max packet in: 32768 bytes
WAR [20150702-17:22:19.526] thr=3   paramiko.transport: Oops, unhandled type 3
DEB [20150702-17:22:35.707] thr=1   paramiko.transport: EOF in transport thread
DEB [20150702-17:22:35.726] thr=3   paramiko.transport: EOF in transport thread
DEB[20150702-17:22:11.519]thr=1 paramiko.transport:启动线程(客户端模式):0x32a00f0L
INF[20150702-17:22:11.604]thr=1 paramiko.transport:已连接(版本2.0,客户端SSHD)
DEB[20150702-17:22:11.686]thr=1 paramiko.transport:kex算法:[u'diffie-hellman-group14-sha1',u'diffie-hellman-group1-sha1',u'diffie-hellman-group1-exchange-sha1']服务器密钥:[u'ssh-rsa']客户端加密:[u'aes256-cbc',u'aes192-cbc',u'aes128-cbc',u'aes128-cbc']服务器加密:[u'aes256-cbc',u'aes192-cbc']客户端mac:[u'hmac-sha1',u'hmac-sha1-96']服务器mac:[u'hmac-sha1',u'hmac-sha1-96']客户端压缩:[u'none',u'zlib']服务器压缩:[u'none',u'zlib']客户端语言:[u']服务器语言:[u']kex如下?False
DEB[20150702-17:22:11.687]thr=1 paramiko.transport:同意的密码:本地=aes128 cbc,远程=aes128 cbc
DEB[20150702-17:22:11.687]thr=1 paramiko.transport:使用kex diffie-hellman-group14-sha1;服务器密钥类型ssh-rsa;密码:本地aes128 cbc,远程aes128 cbc;mac:本地hmac-sha1,远程hmac-sha1;压缩:本地无,远程无
DEB[20150702-17:22:12.020]thr=1 paramiko.transport:切换到新钥匙。。。
DEB[20150702-17:22:12.026]thr=2 paramiko.transport:正在尝试公钥身份验证。。。
DEB[20150702-17:22:12.188]thr=1 paramiko.transport:userauth正常
INF[20150702-17:22:14.894]thr=1 paramiko.transport:Auth banner:
INF[20150702-17:22:15.078]thr=1 paramiko.transport:身份验证继续。。。
DEB[20150702-17:22:15.078]thr=1 paramiko.transport:Methods:[u'password',u'publickey',u'keyboard-interactive']
DEB[20150702-17:22:15.168]thr=3 paramiko.transport:启动线程(客户端模式):0x33263c8L
INF[20150702-17:22:15.253]thr=3 paramiko.transport:已连接(版本2.0,客户端SSHD)
DEB[20150702-17:22:15.335]thr=3 paramiko.transport:kex算法:[u'diffie-hellman-group14-sha1',u'diffie-hellman-group1-sha1',u'diffie-hellman-group1-exchange-sha1']服务器密钥:[u'ssh-rsa']客户端加密:[u'aes256-cbc',u'aes192-cbc',u'aes128-cbc',u'aes128-cbc']服务器加密:[u'aes256-cbc',u'aes192-cbc']客户端mac:[u'hmac-sha1',u'hmac-sha1-96']服务器mac:[u'hmac-sha1',u'hmac-sha1-96']客户端压缩:[u'none',u'zlib']服务器压缩:[u'none',u'zlib']客户端语言:[u']服务器语言:[u']kex如下?False
DEB[20150702-17:22:15.335]thr=3 paramiko.transport:同意的密码:本地=aes128 cbc,远程=aes128 cbc
DEB[20150702-17:22:15.335]thr=3 paramiko.transport:使用kex diffie-hellman-group14-sha1;服务器密钥类型ssh-rsa;密码:本地aes128 cbc,远程aes128 cbc;mac:本地hmac-sha1,远程hmac-sha1;压缩:本地无,远程无
DEB[20150702-17:22:15.671]thr=3 paramiko.transport:切换到新键。。。
DEB[20150702-17:22:15.680]thr=2 paramiko.transport:为[]添加ssh rsa主机密钥:::e5025a02b8ca851f7f0a2d173161400c
DEB[20150702-17:22:15.680]thr=2 paramiko.transport:正在尝试SSH密钥4e85b76b311684e139c597cbab111fef
DEB[20150702-17:22:15.841]thr=3 paramiko.transport:userauth正常
INF[20150702-17:22:19.246]thr=3 paramiko.transport:Auth banner:
INF[20150702-17:22:19.426]thr=3 paramiko.transport:身份验证继续。。。
DEB[20150702-17:22:19.427]thr=3 paramiko.transport:Methods:[u'password',u'publickey',u'keyboard-interactive']
DEB[20150702-17:22:19.438]thr=2 paramiko.transport:[chan 0]最大数据包长度:32768字节
WAR[20150702-17:22:19.526]thr=3 paramiko.transport:Oops,未处理的类型3
DEB[20150702-17:22:35.707]thr=1 paramiko.transport:传输线程中的EOF
DEB[20150702-17:22:35.726]thr=3 paramiko.transport:传输线程中的EOF
我想知道“未处理的类型3”是否有任何提示?我试图连接到的服务器需要user、pass和keyfile

任何建议都将不胜感激,因为我在这里不知所措。请注意,我可以使用WinSCP等连接到此服务器而不会出现问题

谢谢


-Joris.

看起来帕拉米科有一个未解决的问题:看起来帕拉米科有一个未解决的问题: