December 1, 2009 | Posted by
admin | Category: Linux Administration
How to Turn off Mod Security OR How to disable Mod Security for an account?
Mod_Security for an account is turned off/disabled on depending upon the version of Mod_Security i.e. it can be disabled in .htaccess file in modsecurity1 and have to disable it in VirtualHost entry of a domain in modsecurity2. Apache 1.x supports Mod Security1 and Apache 2.x supports Mod Securiry2. To find out the version of Apache, execute
httpd -v
Mod Security1:
Create a .htaccess file in an account
vi .htaccess
and insert the following:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
Mod Security2:
You cannot disable mod security in a .htaccess file here (it’s setup this way to enhance security). You have to turn off mod security in the VirtualHost of the domain in the Apache configuration file. Edit the configuration file:
vi /etc/httpd/conf/httpd.conf
scroll down to the VirtualHost of the domain and place the following lines:
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
Save the configuration file and restart the Apache service.
service httpd restart
Comments Off on Howto: disable Mod Security for an account
December 1, 2009 | Posted by
admin | Category: Scripts
Shell Script to email Successful Ftp Logins.
This Shell script will search the server logs on daily basis and will email you the successful Ftp Logins of the day. The ftp logs are saved in the /var/log/messages file as by default there is no separate log file for Ftp in Linux.
Create a file /home/script/ftplogins.sh and paste the below code:
#!/bin/bash
#Retrieve the current date
CUR_DATE=`date +”%b %e”`
#Create a temporary file to store the logs
touch /tmp/out.txt
echo “List Follows” > /tmp/out.txt
#Search the successful attempts and save in the temporary file
/bin/grep “$CUR_DATE” /var/log/messages | grep pure-ftpd | grep logged >> /tmp/out.txt
#Email the contents of the file to your email address
/bin/mail -s “Successful Ftp Login Attempts on ‘$CUR_DATE'” youremail@yourdomain.com < /tmp/out.txt
Save the file. You now have to schedule a cron to execute the file once in a day to search logs. Edit the cron file
crontab -e
and add the following cron job
59 23 * * * /bin/sh /home/script/ftplogins.sh
Note:
1) This script will work with Pure-Ftpd server. You will have to edit the search string a bit according to your Ftp server.
2) If you copy/paste the script as it is in shell, the single and double quotes may change to dots (.) so make sure you correct them before executing the script.
November 29, 2009 | Posted by
admin | Category: Scripts
Shell Script to search Failed Ftp Login Attempts
This Shell script will search the server logs on daily basis and will email you the Failed Ftp Login Attempts of the day. The ftp logs are saved in the /var/log/messages file as by default there is no separate log file for Ftp in Linux.
Create a file /home/script/failedftp.sh and paste the below code:
#!/bin/bash
#Retrieve the current date
CUR_DATE=`date +”%b %e”`
#Create a temporary file to store the logs
touch /tmp/out.txt
echo “List Follows” > /tmp/out.txt
#Search the failed attempts and save in the temporary file
/bin/grep “$CUR_DATE” /var/log/messages | grep pure-ftpd | grep failed >> /tmp/out.txt
#Email the contents of the file to your email address
/bin/mail -s “Failed Ftp Login Attempts on ‘$CUR_DATE’ ” youremail@yourdomain.com < /tmp/out.txt
Save the file. You now have to schedule a cron to execute the file once in a day to search logs. Edit the cron file
crontab -e
and add the following cron job
59 23 * * * /bin/sh /home/script/failedftp.sh
Note:
1) This script will work with Pure-Ftpd server. You will have to edit the search string a bit according to your Ftp server.
2) If you copy/paste the script as it is in shell, the single and double quotes may change to dots (.) so make sure you correct them before executing the script.
Comments Off on Script to email failed Ftp login attempts
November 29, 2009 | Posted by
admin | Category: Linux Administration
How to Disable Directory Listing? You may want to hide directory listings because by default Webservers look for an index file under every directory and if not found, they list the files and directories under it on browsing the directory.
To disable Directory Listing for an account recursively:
1) Create a .htaccess file under the directory
vi .htaccess
2) Add Options directive as follows:
Options -Indexes
3) Save the file.
You now will see a Forbidden message on accessing a directory that do not include an index file.
November 28, 2009 | Posted by
admin | Category: Plesk Management
Error:
Error message “Error: Unable to create the domain example.com because a DNS record pointing to the host example.com already exists.”
The error message is displayed when you add a domain from Plesk control panel and it fails. The reason it fails is because the DNS records of the domain already exist in the psa database. The tables dns_recs and dns_zone holds the DNS records for a domain.
In order to add the domain example.com, you will have to remove the DNS entries from the tables dns_recs and dns_zone.
1) Goto Mysql prompt:
root@host [~]# mysql -uadmin -p `cat /etc/psa/.psa.shadow`
2) Use the psa database
mysql> use psa;
3) Remove the DNS entries from the dns_recs and dns_zone tables:
mysql> delete from dns_recs where dns_zone_id=10;
mysql> delete from dns_zone where id=10;
where, 10 is the dns_zone_id of the domain example.com.
4) Restart the mysql service:
root@host [~]# service mysqld restart
You should now be able to add the domain from Plesk control panel successfully.