Having trouble with getting Enterprise traps to be encrypted with net-snmp - snmp

I am at a loss on this one.
I am using net-snmp version 5.7.3 and recently added support in the application to support SNMP v3.
SNMP GETS are working flawlessly with any combination of Auth and Priv protocol. I can see the encrypted PDU's when I capture with Wireshark and the MIB browser is able to decode and all works fine.
The problem I am having is with SNMP v3 traps. For the life of me I cannot get Enterprise traps to be encrypted. Wireshark capture shows them clearly going out in clear text.
Here is my relevant configuration:
In /etc/snmp/snmpd.conf I have:
master agentx
agentaddress udp:161
engineID 43f8513afdd8a1648e63a728be8625
rouser allenmcw priv
trapsess -v 3 -u allenmcw -a SHA -A <authPass>-x AES -X <privPass> <IP address>
In /usr/lib/snmp/snmpd.conf I have:
usmUser 1 3 "43f8513afdd8a1648e63a728be8625" "allenmcw" "allenmcw" NULL .1.3.6.1.6.3.10.1.1.3 0x11c712fff7718594a12d2444a3356405a31b3c9c .1.3.6.1.6.3.10.1.2.4 0x11c712fff7718594a12d2444a3356405 0x
setserialno 746862596
##############################################################
#
# snmpNotifyFilterTable persistent data
#
##############################################################
engineBoots 42
oldEngineID "43f8513afdd8a1648e63a728be8625"
For trapsess I have tried the following variation as my understanding is that the passphrase, etc should be picked up with the usmUser entry.
trapsess -v 3 -u allenmcw -l authPriv
Note that this last option results in NO trap going out at all! The -l option should be valid based on all research I have done but it is not working for me.
It should be NOTED that the COLD start trap sent out by net-snmp itself IS getting encrypted, but NO enterprise level traps are.
I confess to being somewhat lost at this point as to what the problem could be.
Thanks for any guidance.
Allen

Have the solution. I suspect this occurred because in our environment we run a separate trap daemon to send all the enterprise traps.
Rather than have clear text passwords in the /etc/snmp/snmpd.conf the following will allow the trap daemon to use the HASHED version of the passwords which comes from /usr/lib/snmp/snmpd.conf
Here is the corrected trapsess line:
trapsess -v 3 -u allenmcw -3m 0x9d833d009db321cec1d2f1ed737bf11aff770fa1 -3M 0x9d833d009db321cec1d2f1ed737bf11a <IP address>
These hashed values were pulled from the other snmpd.conf referenced.

Related

Starting bootcamp - MacTerminal and Github SSH fingerprint don't match

I have been following the steps of the courses pre-work, including:
checking for, generating, copy/paste, and
saving the SSH keys to GitHub.
But when I am instructed to check the matching fingerprints using "ssh -T git#github.com", the prints don't match.
I've even started from the beginning clear through, but they still don't match.
Thought I'd reach out here before using my 1 tutoring.
Hopefully the screenshot showing what I see helps(link).
EDIT- I understand there's some stuff in there that shouldn't be, I was just trying things for diff results. I would just like to know where I went wrong and how to avoid it.
What you ssh is the remote site SSH key fingerprint, not you registered SSH key fingerprint.
You see (or should see if you are contacting the correct github.com) the fingerprints exposed with api.github.com/meta as explained here.
Using jq, you can add them to your ~/.ssh/known_hosts with:
curl --silent https://api.github.com/meta \
| jq --raw-output '"github.com "+.ssh_keys[]' >> ~/.ssh/known_hosts
From there, you can test your connection with ssh -Tv github.com, and check if you see a welcome message:
Hi username!
You've successfully authenticated, but GitHub does not provide shell access

Getting Snmpwalk Timeout Error for AIX Server

I am trying to run the batch file which will do snmp walk for two AIX server. Here the problem is for the first device the walk is completed successfully but for the second device it is throwing "SNMP Timeout Error".
I have tried using the batch file which i created and using snmpwalk.exe. In snmpwalk.exe for both device the walk is happening but through batch file the device which is processing first will give the correct result and for the second one it is throwing timeout error.
#echo off
"C:\Program Files (x86)\test\snmpwalk.exe" -v3 -u test -a MD5 -A XXX -x DES -X YYY 172.21.20.19 .1.3
"C:\Program Files (x86)\test\snmpwalk.exe" -v3 -u test -a MD5 -A XXX -x DES -X ZZZ 172.21.20.21 .1.3
In environment where multiple devices enabled with SNMP, the snmpEngineID must be unique as it is the unique identifier.
In some cases, using cloned devices creates duplicate snmpEngineID in network results in above mentioned behavior (i.e., throwing SNMP timeout). In order to avoid this, do reset the hostID once cloned. Reference.

snmp v3 traps not working when configuring same user with different authentication type

I am using Linux based snmp (net-snmp) in my Linux device. To receive snmp trap on Linux host machine, I have configured snmptrapd in /etc/snmp/snmptrapd.conf file as below (After stopping snmpd daemon)
createUser user MD5 "password123" DES "encrypt123"
authuser log user authPriv
Above configuration allow me to receive snmp trap on Linux host machine when I execute below command from my Linux device
snmptrap -Ci -v3 -u user -a MD5 -A password123 -x DES -X encrypt123 -l authPriv 10.103.0.110 '' Test-MIB::statusChangeNotification Test-MIB::statusChangeAlarm s 'status change'
Now if I execute above snmptrap command with same user and SHA/DES configuration (as below) then in that case snmptrap command is failing with "snmpinform: Authentication failure (incorrect password, community or key)" error message. (snmptrapd is stopped and started after SHA/DES configuration as above.)
snmptrap -Ci -v3 -u user -a SHA -A password123 -x DES -X encrypt123 -l authPriv 10.103.0.110 '' Test-MIB::statusChangeNotification Test-MIB::statusChangeAlarm s 'status change'
Can anybody suggest possible reason behind this error?
Does snmptap command maintain usmUser table which not allow same user entry with different authentication type?
Is there any way to reset usmUser table?
Is there any additional configuration required?
Have you tried removing the quotation marks from both your username and password in the snmptrapd.conf?
It should not work. This is absolutely expected behavior. The user configuration should match on both sides (trap sender and trap receiver).
The SHA1 and MD5 are totally different auth protocols. They do produce different hash codes for the same input data.

snmpwalk shows no response but another SNMP client & Wireshark works fine

I am not getting SNMP traps using snmpwalk. However another SNMP client ("ManageEngine") on the same Windows PC, easily gets all the traps. Also the Wireshark shows that the traps are arriving quite fine.
Please guide me, am I doing something wrong?.
the command:
snmpwalk.exe -v 2c -c public -t 10 IP:Port
Timeout: No Response from IP:Port
You are able to receive trap because your manager on local machine is listening to traps send by remote machine , at port 162.
This does not mean snmpwalk will work. Because in that you are client and sending snmp query to remote host at port 161.
Reason for not responding May be access control list at remote end.
Wrong community string..
Please check at very first that your server is actively listening for query
Check can be done by nmap for listening
Nmap -sU ip -p 161
snmpwalk is not suppose to receive any traps by design. It is used to traverse the MIB tree using GET-NEXT, GET-BULK requests.
Instead you should be using snmptrapd to receive traps.

How to clear terminal after SSH login?

I am trying to connect to a server via ssh. Once connected, terminal should be cleared.
Due to generated keys, I can connect to the server via ssh usr#svr without being prompted a password. This works.
In order to get rid off
The programs included with the Debian GNU/Linux system are free
software; the exact distribution terms for each program are described
in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
I would usually just type clear. However, I would prefer not to type this every time but automate the procedure instead.
ssh usr#svr "clear" --> "TERM environment variable not set.". I googled several solutions about unset environment variables, but without success.
So instead, I tried ssh -t usr#vr "clear"; this successfully clears the terminal, but also closes the connection right away ("Connection to IP closed."). Computer connects to server, clears the screen, closes the connection.
Next attempt was to create a bash script on the server to be run after connecting to it.
#/bin/bash
clear
## cl.sh, chmod +x
ssh usr#svr ./cl.sh --> "TERM environment variable not set.".
Another attempt was to create a bash script connecting to the server and clearing the terminal via ENDSSH.
#/bin/bash
ssh usr#svr <<'ENDSSH'
clear
ENDSSH
## sc.sh, chmod +x
Running this results in:
> ./sc.sh
Pseudo-terminal will not be allocated because stdin is not a terminal.
Linux raspberrypi 3.18.7-v7+ #755 SMP PREEMPT Thu Feb 12 17:20:48 GMT 2015 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
TERM environment variable not set.
I am a beginner at this, so please be patient if I have made a very obvious mistake. I tried to be as detailed as possible and researched this before posting, but could not find an answer to my question. For example, commands other than "clear" work (ssh usr#svr ls), but that does not help me.
I have found another easy solution
ssh -t usr#svr 'clear;bash'
The text your question refers to is part of the message-of-the-day (MOTD).
If you can become root on the server, you can just modify that message in /etc/motd. Note that depending on the server's distribution, this file will usually be generated somehow (overwriting any changes), e.g. on Debian it is generated from /etc/motd.tail at boot, so you might have to change that file instead.
See manpage motd(5).
To prevent that message from being printed you can create a file named .hushlogin in your home directory (on the server). SSH to the server and run the command touch ~/.hushlogin. If that file exists then the login shell will no longer print the motd (message of the day) which is what you are seeing.
All startup messages are defined in motd file (/etc/motd).
However if you'd like to having your console cleared to increase privacy, add the following code:
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
Either to your .bash_profile or .bash_logout (on logout). Or by using clear command.
Clearing screen on logout is the default behaviour on Debian Linux distribution.

Resources