如何修改删除 snmptrapd 的 SNMPv3 用户

如何修改/删除 snmptrapd 的 SNMPv3 用户

环境

  • Red Hat Enterprise Linux 7
  • snmptrapd’s SNMPv3 user

问题

如何修改/删除 snmptrapd 的 SNMPv3 用户

决议

如果通过配置文件创建了 SNMPv3 用户,则基本上无法删除它 - 除非停止代理并手动编辑配置文件。

  • 修改 snmptrapd 的 SNMPv3 用户

    1. 创建 snmptrapd 的 SNMPv3 用户。
    2. 启动 snmptrapd 服务。
    # systemctl start snmptrapd
    
    3. 执行 snmptrap 命令。
    # snmptrap -v3 -e 0x80001f88802bfe5615ecf12b5800000000 -a MD5 -A 12345678 -x DES -X 12345678 -l authPriv -u testuser 127.0.0.1 0 linkUp.0
    
    /var/log/messages:
    localhost snmptrapd[3388]: 2016-11-16 04:33:57 localhost [UDP: [127.0.0.1]:37600->[127.0.0.1]:162]:
    DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (0) 0:00:00.00    SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkUp.0
    
    4. 停止 snmptrapd 服务。
    # systemctl stop snmptrapd
    
    5. 将 snmptrapd [OPTIONS] 更改为“-Lsd -C -c /etc/snmp/snmptrapd.conf”。
    * 这是为了刷新 /var/lib/net-snmp/snmptrapd.conf 条目。
    
    ~]# cat /etc/sysconfig/snmptrapd 
    # snmptrapd command line options
    # '-f' is implicitly added by snmptrapd systemd unit file
    # OPTIONS="-Lsd"
    OPTIONS="-Lsd -C -c /etc/snmp/snmptrapd.conf"
    
    6. 修改 /etc/snmp/snmptrapd.conf 中的用户条目。
    
    从:
    createUser -e 0x80001f88802bfe5615ecf12b5800000000 testuser MD5 12345678 DES 12345678
    
    到:
    createUser -e 0x80001f88802bfe5615ecf12b5800000000 testuser MD5 87654321 DES 87654321
    
    7. 启动 snmptrapd 服务。
    # systemctl start snmptrapd
    
    8. 执行 snmptrap 命令。
    
    # snmptrap -v3 -e 0x80001f88802bfe5615ecf12b5800000000 -a MD5 -A 12345678 -x DES -X 12345678 -l authPriv -u testuser 127.0.0.1 0 linkUp.0
    
    /var/log/messages:
    localhost snmptrapd[3388]: Authentication failed for testuser
    
    # snmptrap -v3 -e 0x80001f88802bfe5615ecf12b5800000000 -a MD5 -A 87654321 -x DES -X 87654321 -l authPriv -u testuser 127.0.0.1 0 linkUp.0
    
    /var/log/messages:
    localhost snmptrapd[3388]: 2016-11-16 04:33:57 localhost [UDP: [127.0.0.1]:37600->[127.0.0.1]:162]:
    DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (0) 0:00:00.00    SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkUp.0
    
    9. 停止 snmptrapd 服务。
    # systemctl stop snmptrapd
    
    10. 将 snmptrapd [OPTIONS] 更改为默认选项。
    
    ~]# cat /etc/sysconfig/snmptrapd 
    # snmptrapd command line options
    # '-f' is implicitly added by snmptrapd systemd unit file
    # OPTIONS="-Lsd"
    
    11. 启动 snmptrapd 服务。
    # systemctl start snmptrapd
    
  • 删除 snmptrapd 的 SNMPv3 用户

    1. 创建 snmptrapd 的 SNMPv3 用户。
    2. 启动 snmptrapd 服务。
    # systemctl start snmptrapd
    
    3. 执行 snmptrap 命令。
    # snmptrap -v3 -e 0x80001f88802bfe5615ecf12b5800000000 -a MD5 -A 12345678 -x DES -X 12345678 -l authPriv -u testuser 127.0.0.1 0 linkUp.0
    
    /var/log/messages:
    localhost snmptrapd[3388]: 2016-11-16 04:33:57 localhost [UDP: [127.0.0.1]:37600->[127.0.0.1]:162]:
    DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (0) 0:00:00.00    SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkUp.0
    
    4. 停止 snmptrapd 服务。
    # systemctl stop snmptrapd
    
    5. 将 snmptrapd [OPTIONS] 更改为“-Lsd -C -c /etc/snmp/snmptrapd.conf”。
    * 这是为了刷新 /var/lib/net-snmp/snmptrapd.conf 条目。
    
    
    ~]# cat /etc/sysconfig/snmptrapd 
    # snmptrapd command line options
    # '-f' is implicitly added by snmptrapd systemd unit file
    # OPTIONS="-Lsd"
    OPTIONS="-Lsd -C -c /etc/snmp/snmptrapd.conf"
    
    6. 删除 /etc/snmp/snmptrapd.conf 中的用户条目。
    
    #createUser -e 0x80001f88802bfe5615ecf12b5800000000 testuser MD5 12345678 DES 12345678
    authUser log,execute,net testuser
    
    7. 启动 snmptrapd 服务。
    # systemctl start snmptrapd
    
    8. 执行 snmptrap 命令。
    
    # snmptrap -v3 -e 0x80001f88802bfe5615ecf12b5800000000 -a MD5 -A 12345678 -x DES -X 12345678 -l authPriv -u testuser 127.0.0.1 0 linkUp.0
    
    /var/log/messages:
    No log messages.
    
    9. 停止 snmptrapd 服务。
    # systemctl stop snmptrapd
    
    10. 检查 /var/lib/net-snmp/snmptrapd.conf 中的用户条目 - 没有 testuser 条目。
    ~]# cat /var/lib/net-snmp/snmptrapd.conf | grep testuser
    ~]#
    
    11. 将 snmptrapd [OPTIONS] 更改为默认选项。
    
    ~]# cat /etc/sysconfig/snmptrapd 
    # snmptrapd command line options
    # '-f' is implicitly added by snmptrapd systemd unit file
    # OPTIONS="-Lsd"
    
    12. 启动 snmptrapd 服务。
    # systemctl start snmptrapd
    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值