| 1 | How to setup SNMPv3, a very brief document for Dave to elaborate and | 
|---|
| 2 | do a better job on since I suck at writing documentation and he | 
|---|
| 3 | doesn't ;-) --Wes: | 
|---|
| 4 |  | 
|---|
| 5 | Note: SHA authentication and DES/AES encryption support is only available | 
|---|
| 6 | if you have OpenSSL installed. | 
|---|
| 7 |  | 
|---|
| 8 | Note: encryption support now *is* enabled in the binary releases downloadable | 
|---|
| 9 | from the net-snmp web site. | 
|---|
| 10 |  | 
|---|
| 11 | Note: this description assumes you're using the software compiled from | 
|---|
| 12 | source, and so installed using the default prefix location (/usr/local). | 
|---|
| 13 | If you're working with a vendor-provided system, or have configured | 
|---|
| 14 | things with a different prefix, you'll need to adjust locations accordingly. | 
|---|
| 15 |  | 
|---|
| 16 | CREATING THE FIRST USER: | 
|---|
| 17 | ------------------------ | 
|---|
| 18 | First, you need to create a new snmpv3 user and give them rights to | 
|---|
| 19 | do things: | 
|---|
| 20 |  | 
|---|
| 21 | net-snmp-config --create-snmpv3-user -a "my_password" myuser | 
|---|
| 22 |  | 
|---|
| 23 | WARNING: SNMPv3 pass phrases must be at least 8 characters long! | 
|---|
| 24 |  | 
|---|
| 25 | The above line creates the user "myuser" with a password of | 
|---|
| 26 | "my_password" (and uses MD5 and DES for protection).  (Note that | 
|---|
| 27 | encryption support isn't enabled in the binary releases downloadable | 
|---|
| 28 | from the net-snmp web site.)  net-snmp-config will also add a line | 
|---|
| 29 | to your snmpd.conf file to let that user have read/write access to | 
|---|
| 30 | your agent.  You may want to change this in your snmpd.conf file | 
|---|
| 31 | (see the snmpd.conf manual page).  Run net-snmp-config --help for | 
|---|
| 32 | more information about it. | 
|---|
| 33 |  | 
|---|
| 34 | Start the agent and test your setup: | 
|---|
| 35 | /usr/local/sbin/snmpd | 
|---|
| 36 | [...wait a few seconds...  It will run in the background and | 
|---|
| 37 | return you to your shell immediately.] | 
|---|
| 38 |  | 
|---|
| 39 | snmpget -v 3 -u myuser -l authNoPriv -a MD5 -A my_password localhost sysUpTime.0 | 
|---|
| 40 | [ this should return information about how long your agent has been up] | 
|---|
| 41 |  | 
|---|
| 42 | snmpget -v 3 -u myuser -l authPriv   -a MD5 -A my_password | 
|---|
| 43 | -x DES -X my_password localhost sysUpTime.0 | 
|---|
| 44 | [ this should return similar information, but encrypts the transmission ] | 
|---|
| 45 |  | 
|---|
| 46 | CREATING A SECOND USER: | 
|---|
| 47 | ----------------------- | 
|---|
| 48 | Start the agent (if you didn't do so above). | 
|---|
| 49 |  | 
|---|
| 50 | You can create as many users as you like using the above method, but | 
|---|
| 51 | this details another way of doing it while the agent is running by | 
|---|
| 52 | modifying the user database using the snmp protocol itself: | 
|---|
| 53 |  | 
|---|
| 54 | Now, lets create a second user using the first user (just for fun) | 
|---|
| 55 | for both authentication purposes and as a template (or "cloning | 
|---|
| 56 | source"): | 
|---|
| 57 |  | 
|---|
| 58 | snmpusm -v 3 -u myuser -l authNoPriv -a MD5 -A my_password localhost create wes myuser | 
|---|
| 59 |  | 
|---|
| 60 | The above should have created the user "wes" with the same password as | 
|---|
| 61 | the "myuser" user.  So then, you need to change his password using: | 
|---|
| 62 |  | 
|---|
| 63 | snmpusm -v 3 -u wes -l authNoPriv -a MD5 -A my_password localhost passwd my_password new_passphrase | 
|---|
| 64 |  | 
|---|
| 65 | See, wasn't that easy?  You can now create users.  Wheeee.... | 
|---|
| 66 |  | 
|---|
| 67 | But, you'll have to add a configuration line that allows them access | 
|---|
| 68 | to do things.  Do this with another "rwuser" line in your | 
|---|
| 69 | /usr/local/share/snmp/snmpd.conf file (you'll need to stop and start | 
|---|
| 70 | the agent again, or send the agent a SIGHUP signal): | 
|---|
| 71 |  | 
|---|
| 72 | rwuser wes | 
|---|
| 73 |  | 
|---|
| 74 | Or, optional use the "rouser" token instead of the "rwuser" token to | 
|---|
| 75 | only grant them read-only access. | 
|---|
| 76 |  | 
|---|
| 77 | Now, test your new user: | 
|---|
| 78 |  | 
|---|
| 79 | snmpget -v 3 -u wes -l authNoPriv -a MD5 -A new_passphrase localhost sysUpTime.0 | 
|---|
| 80 |  | 
|---|
| 81 |  | 
|---|
| 82 | FURTHER STUDIES: | 
|---|
| 83 | --------------- | 
|---|
| 84 |  | 
|---|
| 85 | Tired of all those command line authentication options? | 
|---|
| 86 | ---------------------------------------- | 
|---|
| 87 | put something like this in your $HOME/.snmp/snmp.conf file (make it | 
|---|
| 88 | readable only by you!!!): | 
|---|
| 89 |  | 
|---|
| 90 | defSecurityName wes | 
|---|
| 91 | defContext "" | 
|---|
| 92 | defAuthType MD5 | 
|---|
| 93 | defSecurityLevel authNoPriv | 
|---|
| 94 | defAuthPassphrase new_passphrase | 
|---|
| 95 | defVersion 3 | 
|---|
| 96 |  | 
|---|
| 97 | And this is in place the last of the above example lines boils down to: | 
|---|
| 98 |  | 
|---|
| 99 | snmpget localhost sysUpTime.0 | 
|---|
| 100 |  | 
|---|
| 101 | Which is about as simple as I can make it for ya ;-) | 
|---|
| 102 |  | 
|---|