【问题标题】:Paramiko start_server Not WorkingParamiko start_server 不工作
【发布时间】:2015-08-31 15:20:49
【问题描述】:

我创建了一个通过 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 有关。如果有人知道如何解决这个问题,请 发表评论。提前谢谢你。

【问题讨论】:

  • @CivFan,请举例说明如何操作,谢谢。
  • import logging; import sys; logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) -- 用于分隔行的分号,用新行替换它们,然后在此之后运行您的代码。
  • 这是它给我的:debugRusults.txt
  • 我们显然有不同版本的paramikoCrypto。我可以在不同的行上使用外观相似的代码块来追踪很远。但我在_AESNI 处丢失了踪迹——我无法在我的版本中找到任何地方。
  • 我尝试重建 paramiko 和 pycrypto sudo python setup.py build 。没用。

标签: python-2.7 paramiko pycrypto


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-03
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 2013-12-04
    • 2023-02-09
    • 2016-05-25
    • 2018-11-29
    相关资源
    最近更新 更多