尝试使用pysnmp为snmpv3运行getp时,出现错误
pysnmp.smi.error.WrongValueError:WrongValueError({'msg':WrongValueError(),'name':(1、3、6、1、6、3、15、1、2、2、1、5 ,24,48,48,48,48,49,100,51,98,48,48,48,48,55,53,100,49,97,99,49,48,48,49,48,49 ,5,107,107,48,51,48),'idx':3})
from pysnmp.hlapi import *
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
UsmUserData('USERNAME',authKey='AUTHKEY', privKey='PRIVKEY', authProtocol='usmHMACSHAAuthProtocol', privProtocol='usmAESCfb256Protocol',
securityEngineId=OctetString(hexValue='0000303010')),
UdpTransportTarget(('<IP-ADDR>', <PORT>)),
ContextData(),
ObjectType(ObjectIdentity('<MIB-FILE-NAME>','<MIB-NAME>',<INDEX>)))
相同的代码适用于带有社区字符串而不是UsmUserData的SNMP-V2。但是,不适用于SNMP-V3。
回溯时间太长,没有任何线索
File "supy.py", line 15, in <module>
ObjectType(ObjectIdentity('<MIB-FILE-NAME>','<MIB-NAME>',<INDEX>)))
File "/usr/lib/python2.7/site-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 111, in getCmd
lookupMib=options.get('lookupMib', True)))
File "/usr/lib/python2.7/site-packages/pysnmp/hlapi/asyncore/cmdgen.py", line 124, in getCmd
addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget)
File "/usr/lib/python2.7/site-packages/pysnmp/hlapi/lcd.py", line 60, in configure
securityName=authData.securityName
File "/usr/lib/python2.7/site-packages/pysnmp/entity/config.py", line 159, in addV3User
(usmUserEntry.name + (13,) + tblIdx1, 'createAndGo'))
File "/usr/lib/python2.7/site-packages/pysnmp/smi/instrum.py", line 256, in writeVars
return self.flipFlopFsm(self.fsmWriteVar, varBinds, acInfo)
File "/usr/lib/python2.7/site-packages/pysnmp/smi/instrum.py", line 239, in flipFlopFsm
raise origExc
pysnmp.smi.error.WrongValueError: WrongValueError({'msg': WrongValueError(), 'name': (1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 5, 24, 48, 48, 48, 48, 49, 100, 51, 98, 48, 48, 48, 48, 55, 53, 100, 49, 97, 99, 49, 48, 48, 49, 48, 49, 5, 107, 107, 48, 51, 48), 'idx': 3})
请在此处为我们提供一些线索。
答案 0 :(得分:0)
确保您的身份验证和私钥符合基础加密算法所需的最小长度。对于任何算法,键的长度至少应为8个以上字符。
答案 1 :(得分:0)
请在下面找到链接: https://pysnmp.readthedocs.io/en/latest/docs/api-reference.html#high-level-v3arch-asyncore
请检查并确保authProtocol和privProtocol不作为字符串而是作为数字集提及,例如:代替使用'des'作为authprotocol使用(1、3、6、1、6、3、10、1, 2,2)。