Search code examples
python-2.7paramikopycrypto

Paramiko start_server Not Working


I created a program for accessing a server via Paramiko and sockets.

#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

When I launch the server, and get a client to connect to it, I get this error :

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

It has something to do with the Crypto I added for password authentication. If anyone knows howto solve this issue, please leave a comment. Thank you in advance.


Solution

  • All I had to do is replace all the alpha versions of pycrypto with the stable version. The current stable version (Sept. 1st 2015) for pycrypto is 2.6.1 and for paramiko it's 1.14.2.