IMAP SMTP auth & SPAM
These handy bits of one line foo are straight from one of the smartest and strangest admins I have had the pleaure of meeting. He is always crafting these sort of tools for use.
Tally of who failed SMTP Auth login:
grep "smtp_auth: .* connect from" /var/log/messages | awk '{print $2"/"$1"/2007:"$3"\t"$9"\t"$10}' | sed -e "s/\[//g" -e "s/\]//g"
And their IPs
grep "smtp_auth: SMTP connect from" /var/log/messages | awk '{print $10}' | sed -e "s/\[//g" -e "s/\]//g" | sort -n | uniq -c | sort -nr | head -20
Tally of who succeeded SMTP Auth login:
grep "smtp_auth: smtp_auth: SMTP user " /var/log/messages | grep "logged in from " | awk '{print $2"/"$1"/2007:"$3"\t"$9"\t"$16}' | sed -e "s/\[//g" -e "s/\]//g"
And their IPs
grep "smtp_auth: smtp_auth: SMTP user " /var/log/messages | grep "logged in from " | awk '{print $16}' | sed -e "s/\[//g" -e "s/\]//g" | sort -n | uniq -c | sort -nr | head -20
Quick Basic Authentication
Within the servers Apache configuration, find the directives involving the virtual host you are targeting. Edit the configuration and add statements consisting of
<Directory /full/path/to/directory/to/password/protect> AllowOverride All </Directory>
The ‘AllowOverride’ directive tells apache to read the .htaccess file in the specified directory.Inside the directory that has been specified for the password protection, create an .htaccess file
Enter the following text in the .htaccess file
AuthName "Title edit as needed" AuthType Basic require valid-user AuthUserFile /full/path/to/.htpasswdOnce this is in place, create the .htpasswd file called for by the .htaccess file just created. To create the password file that will contain the username and password for the login, use the following command (It is adviseable to place this file outside of a location served by the web server)
/usr/bin/htpasswd -c /full/path/to/.htpasswd username
Enter the password for the user when prompted.
Finally, restart Apache.