Paramiko start_server 不工作

Paramiko start_server Not Working

我创建了一个通过 Paramiko 和套接字访问服务器的程序。

#make imports
from socket import *
from datetime import datetime
from pickle import load, dump
from Crypto.Hash import SHA256
from subprocess import check_output as exeCMD
from sqlite3 import connect as SQLconnect
import paramiko, sys, threading, os

#get password from file
pasword = load(open("usrData/pswd.txt", "rb"))

#class for initiating server connection with client
class Server(paramiko.ServerInterface):
    #initialize object
    def __init__(self):
        self.event = threading.Event()
    #check password for user entry
    def check_auth_password(self, username, password):
        #where the error is
        givenpswdHash = SHA256.new(password)
        print(givenpswdHash.hexdigest())
        if (username in unameList) and (givenpswdHash.hexdigest() == pasword):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED

#what to execute in command line
def terminal(hostIP, hostPort, hostKeyPath, hostKeyPswd):
    #create sockets before this etc...
    #create server instance
    server = Server()
    #get server onto session
    #where we call out server function
    session.start_server(server=server)
    #continue talking to client

当我启动服务器并让客户端连接到它时,出现此错误:

No handlers could be found for logger "paramiko.transport"
Traceback (most recent call last):
  File "./terminalServer.py", line 212, in <module>
    main()
  File "./terminalServer.py", line 209, in main
    terminal(ip, port, keyPath, keyPswd)
  File "./terminalServer.py", line 142, in terminal
    session.start_server(server=server)
  File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 471, in start_server
    raise e
ValueError: CTR mode needs counter parameter, not IV

和我加的密码验证用的Crypto有关。如果有人知道如何解决这个问题,请 发表评论。提前谢谢你。

我所要做的就是将 pycrypto 的所有 alpha 版本替换为稳定版本。 pycrypto 的当前稳定版本(2015 年 9 月 1 日)是 2.6.1,paramiko 是 1.14.2。