mixtli / net-snmp

ruby library for snmp. uses ffi to connect to net-snmp libs
MIT License
28 stars 14 forks source link

privacy protocol (des|aes) and privacy protocol pass phrase #2

Closed naquad closed 12 years ago

naquad commented 13 years ago

Hi.

I can't find how to set privacy protocol and privacy protocol pass phrase in net-snmp. Is there some way?

Just trying to do the same as snmpget -v3 -a MD5 -A 'xxxx1' -u user -x AES -X 'xxx2' -l authPriv example.com .1.3.6.1.4.1.2021.4.5.0 does, but with net-snmp.

Tried that:

#!/usr/bin/ruby -w

require 'net-snmp'

Net::SNMP::Session.open(:peername => 'example.com',
                        :version => '3',
                        :security_level => Net::SNMP::Constants::SNMP_SEC_LEVEL_AUTHPRIV,
                        :auth_protocol => :md5,
                        :priv_protocol => :aes,
                        :username => 'user',
                        :password => 'xxx1') do |sess|

  pdu = sess.get([".1.3.6.1.4.1.2021.4.5.0"])
  pdu.print
end

and i get error:

/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/struct.rb:225: warning: method redefined; discarding old align
/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/struct.rb:126: warning: previous definition of align was here
/usr/lib/ruby/gems/1.9.1/gems/nice-ffi-0.4/lib/nice-ffi/library.rb:142: warning: shadowing outer local variable - args
/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/library.rb:149: warning: method redefined; discarding old snmp_select_info
/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/library.rb:149: warning: method redefined; discarding old snmp_select_info
/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/library.rb:149: warning: method redefined; discarding old snmp_read
/usr/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/library.rb:149: warning: method redefined; discarding old snmp_read
/usr/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.2/lib/net/snmp/oid.rb:34: warning: method redefined; discarding old oid
/usr/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.2/lib/net-snmp.rb:23: warning: method redefined; discarding old initialize
/usr/lib/ruby/gems/1.9.1/gems/nice-ffi-0.4/lib/nice-ffi/struct.rb:331: warning: previous definition of initialize was here
SNMP Error: Net::SNMP::Error
message = Net::SNMP::Error
status = 1
errno = 0
snmp_err = -42
snmp_msg = USM generic error
/usr/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.2/lib/net/snmp/session.rb:199:in `error': snmp_sess_synch_response (Net::SNMP::Error)
    from /usr/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.2/lib/net/snmp/session.rb:399:in `send_pdu'
    from /usr/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.2/lib/net/snmp/session.rb:143:in `get'
    from test.rb:13:in `block in <main>'
    from /usr/lib/ruby/gems/1.9.1/gems/net-snmp-0.2.2/lib/net/snmp/session.rb:46:in `open'
    from test.rb:5:in `<main>'

I suspect this happens because I didn't set privacy protocol and privacy pass phrase.

Thanks.

mixtli commented 12 years ago

I cut a new release with options auth_password and priv_password. Closing.