2015-08-31 19 views
3

我創建了一個通過Paramiko和套接字訪問服務器的程序。Paramiko start_server不工作

#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 

它是與我添加了密碼驗證的加密。如果有人知道如何解決這個問題,請 發表評論。先謝謝你。

+0

@CivFan,請提供一個如何做的例子,謝謝。 – bendacoder

+1

'進口伐木;進口系統; logging.basicConfig(stream = sys.stderr,level = logging.DEBUG)' - 用於分隔行的分號,用新行代替,然後在此之後運行你的代碼。 – CivFan

+0

以下是它給我的:[debugRusults.txt](https://gist.github.com/bendacoder/26119ecf539b2c367e57) – bendacoder

回答

2

我所要做的就是用穩定版本替換pycrypto的所有alpha版本。目前穩定版本(2015年9月1日)的pycrypto是2.6.1,而paramiko是1.14.2。