vi /etc/sysconfig/snmpd.options
OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a -x 127.0.0.1 192.168.1.254"
service snmpd reload
vi /etc/sysconfig/snmpd.options
OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a -x 127.0.0.1 192.168.1.254"
service snmpd reload
nano /etc/firewalld/services/snmp.xml
Contents of the file is as following (Please mind the using of udp port 161)
<?xml version="1.0" encoding="utf-8"?> <service> <short>SNMP</short> <description>SNMP protocol</description> <port protocol="udp" port="161"/> </service>
firewall-cmd --reload
firewall-cmd --zone=public --add-service snmp --permanent
firewall-cmd --reload
Now Test Snmp Status from another server
snmpwalk -v 2c -c public IP.of.target.server
How to block access by user agent in Nginx. In this configuration, i will use ngx_http_map_module.
Inside http section:
include /etc/nginx/blacklist;
Inside server section (virtual host). We will return 444 status code.
if ($block_ua) {
return 444;
}
The blacklist file (example)
map $http_user_agent $block_ua {
default 0;
~*profound 1;
~*scrapyproject 1;
~*netcrawler 1;
~*nmap 1;
~*sqlmap 1;
~*slowhttptest 1;
~*nikto 1;
~*jersey 1;
~*brandwatch 1;
~*magpie-crawler 1;
~*mechanize 1;
~*python-requests 1;
~*redback 1;
}
For testing:
aelius@macbook:~$ curl --head -A "profound" https://www.unixteacher.org/ curl: (52) Empty reply from server
What is http status 444 ?
A non-standard status code used to instruct nginx to close the connection without sending a response to the client, most commonly used to deny malicious or malformed requests.
Harden bash_history and bash configuration files by making them append-only:
chattr +a /home/user/.bash_history
chattr +a /home/user/.bash_profile
chattr +a /home/user/.bash_login
chattr +a /home/user/.profile
chattr +a /home/user/.bash_logout
chattr +a /home/user/.bashrc
Harden env variables by adding the following lines to /home/user/.bashrc:
shopt -s histappend
readonly PROMPT_COMMAND="history -a"
readonly HISTFILE
readonly HISTFILESIZE
readonly HISTSIZE
readonly HISTCMD
readonly HISTCONTROL
readonly HISTIGNORE
histappend tells bash to append the last $HISTSIZE lines to the $HISTFILE file when an interactive shell exits. PROMPT_COMMAND executes the given command prior to issuing each prompt. history -a appends the command typed just before the current one to $HISTFILE.
Disable access to other shells:
chmod 750 csh
chmod 750 tcsh
chmod 750 ksh
run
setcap cap_net_bind_service+ep /path/to/bin/javaex: setcap cap_net_bind_service+ep /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
On the SSH Server 1. Check OpenSSH version (requires OpenSSH 9.0+): ssh -V 2. Edit SSH server configuration: Edit /etc/ssh/sshd_config...
For those not using wordpress at all and just want to block annoying scraper bots:
or better yet: