0

I'm trying to learn how to use pySNMP and I'm trying to simply do a get using encryption with SNMPv3. Here's the code.

iterator = getCmd(
    SnmpEngine(),
    UsmUserData(
        userName='jdLaptop',      #username
        authKey= 'aep123',         #authentication password
        privKey='aep123',         #encryption password
        authProtocol= usmHMACMD5AuthProtocol,
        privProtocol= usmAesCfb128Protocol,
    ),
    UdpTransportTarget(('10.98.240.100', 161)),
    ContextData(),
    ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysName', 0))
)

#this print code is stolen from the documentation
errorIndication, errorStatus, errorIndex, varBinds = next(iterator)

if errorIndication:
    print(errorIndication)

elif errorStatus:
    print('%s at %s' % (errorStatus.prettyPrint(),
                        errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))

else:
    for varBind in varBinds:
        print(' = '.join([x.prettyPrint() for x in varBind]))

Any clue what the issue is here? Most of this code is directly copied from the (terrible) documentation.

I get several errors, including a value constraint error on the first password and a Wrong Value error.

  • Both passwords must be at least 8 characters long (an SNMPv3 limitation, not pysnmp). I tested everything else you have and was able to get a response with no problem. –  May 15 '22 at 23:14
  • @RichardDodson You are my hero, I've spent hours pulling my hair out and was in the middle of switching to SNMP4J to solve the problem. It works 100% now! Sorry for the rookie mistake, we've always used SNMPv2 so I'm not used to the intricacies. – J.D. Black May 16 '22 at 18:01
  • The same thing happened to me before. Glad it's working. –  May 16 '22 at 18:55

0 Answers0