snmpv3 getone fails while trying via pysnmp (Wrong

2019-08-30 05:16发布

while trying to run get one with pysnmp for snmpv3, getting below error

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>)))

The same code works for SNMP-V2 with community string instead of UsmUserData. However, not working for SNMP-V3.

The traceback is too long and no clue

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})

Please help us with some clue here.

标签: pysnmp
1条回答
来,给爷笑一个
2楼-- · 2019-08-30 06:13

Make sure your authentication and private keys comply with the minimum length required by the underlying crypto algorithms. Perhaps the keys should be at least 8+ characters for any algorithm.

查看更多
登录 后发表回答