venerdì 14 settembre 2012

Enable htaccess Apache in Ubuntu


Enable htacces for directories

we know that htaccess permission must on apache web server like making SEF urls, directory permissions..etc.here we discuss about how to check .htaccess enabled.
Before we begin this tutorial, please make sure you make a backup copy of the originalhttpd.conf apache configuration file located in apache installation folder in case we make a mistake, this way we can always go back to the original configuration file
Now open
httpd.conf
file with note pad and find the below text
<directory />
    Options FollowSymLinks
    AllowOverride none
    Order deny,allow
    Deny from all
    Satisfy all
</directory>
Then replace AllowOverride none to AllowOverride All. Modified version looks as below
<directory />
    Options FollowSymLinks
    AllowOverride all
    Order deny,allow
    Deny from all
    Satisfy all
</directory>
Above change tells the apache to use .htaccess as per directory bases.
Now we can use .htaccess files .

Remember

Remember while uploading .htaccess file to remote server make sure the file transfer in ASCII mode, generally with windows operating system FTP programs use binary mode.
Generally FTP programs doesn’t display the .htaccess files by default ,we must force the FTP program to show hidden files like .htaccess files.
When you save .htaccess file with note pad it saves as .htaccess.txt .Make sure .htaccess is a file extension not a file name with empty name.

venerdì 10 agosto 2012

How to secure an Ubuntu 12.04 LTS server - The Basics



This guide is based on various community forum posts and webpages. Special thanks to all. All comments and improvements are very welcome as this is purely a personal experimental project at this point and must be considered a work in progress. 
This guide is intended as a relatively easy step by step guide to:
Harden the security on an Ubuntu 12.04 LTS server by installing and configuring the following:
  1. Install and configure Firewall - ufw
  2. Secure shared memory - fstab 
  3. SSH - Disable root login and change port 
  4. Protect su by limiting access only to admin group 
  5. Harden network with sysctl settings 
  6. Disable Open DNS Recursion - Bind9 DNS 
  7. Prevent IP Spoofing
  8. Harden PHP for security 
  9. Install and configure Apache application firewall - ModSecurity
  10. Protect from DDOS (Denial of Service) attacks with ModEvasive
  11. Scan logs and ban suspicious hosts - DenyHosts and Fail2Ban
  12. Intrusion Detection - PSAD
  13. Check for RootKits - RKHunter and CHKRootKit
  14. Scan open Ports - Nmap
  15. Analyse system LOG files - LogWatch
  16. SELinux - Apparmor
  17. Audit your system security - Tiger
If you are looking for a GUI script to install and configure all the steps explained here automatically,
visit How to secure an Ubuntu 12.04 LTS server - Part 2 The GUI Installer script
Requirements:
  • Ubuntu 12.04 LTS server with a standard LAMP stack installed.

1. Firewall - UFW

  • A good place to start is to install a Firewall. 
  • UFW - Uncomplicated Firewall is a basic firewall that works very well and easy to configure with its Firewall configuration tool - gufw, or use  Shorewall, fwbuilder, or Firestarter.
  • Use Firestarter GUI to configure your firewall or refer to the Ubuntu Server Guide,  UFW manual pages or the Ubuntu UFW community documentation.
  • Install UFW and enable, open a terminal window and enter :
sudo apt-get install ufw
sudo ufw enable
  • Check the status of the firewall.
sudo ufw ufw status verbose
  • Allow SSH and Http services.
sudo ufw allow ssh
sudo ufw allow http

2. Secure shared memory.

  • /dev/shm can be used in an attack against a running service, such as httpd. Modify /etc/fstab to make it more secure.
  • Open a Terminal Window and enter the following :
sudo vi /etc/fstab
  • Add the following line and save. You will need to reboot for this setting to take effect :
tmpfs     /dev/shm     tmpfs     defaults,noexec,nosuid     0     0

3. SSH Hardening - disable root login and change port.

  • The easiest way to secure SSH is to disable root login and change the SSH port to something different than the standard port 22. 
  • Before disabling the root login create a new SSH user and make sure the user belongs to the admin group (see step 4. below regarding the admin group).
  • If you change the SSH port also open the new port you have chosen on the firewall and close port 22.
  • Open a Terminal Window and enter :
sudo vi /etc/ssh/sshd_config
  • Change the following and save.
Port 
Protocol 2
PermitRootLogin no
  • Restart SSH server, open a Terminal Window and enter :
sudo /etc/init.d/ssh restart

4. Protect su by limiting access only to admin group.

  • To limit the use of su by admin users only we need to create an admin group, then add users and limit the use of su to the admin group.
  • Add a admin group to the system and add your own admin username to the group by replacing below with your admin username.
  • Open a terminal window and enter:
sudo groupadd admin
sudo usermod -a -G admin 
sudo dpkg-statoverride --update --add root admin 4750 /bin/su

5. Harden network with sysctl settings.

  • The /etc/sysctl.conf file contain all the sysctl settings.
  • Prevent source routing of incoming packets and log malformed IP's enter the following in a terminal window:
sudo vi /etc/sysctl.conf
  • Edit the /etc/sysctl.conf file and un-comment or add the following lines :
# IP Spoofing protection
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# Ignore ICMP broadcast requests
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Disable source packet routing
net.ipv4.conf.all.accept_source_route = 0
net.ipv6.conf.all.accept_source_route = 0 
net.ipv4.conf.default.accept_source_route = 0
net.ipv6.conf.default.accept_source_route = 0

# Ignore send redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0

# Block SYN attacks
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 5

# Log Martians
net.ipv4.conf.all.log_martians = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Ignore ICMP redirects
net.ipv4.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0 
net.ipv6.conf.default.accept_redirects = 0

# Ignore Directed pings
net.ipv4.icmp_echo_ignore_all = 1
  • To reload sysctl with the latest changes, enter:
sudo sysctl -p

6. Disable Open DNS Recursion - BIND DNS Server.

  • Open a Terminal and enter the following :
sudo vi /etc/bind/named.conf.options
  • Add the following to the Options section :
recursion no;
  • Restart BIND DNS server. Open a Terminal and enter the following :
sudo /etc/init.d/bind9 restart

7. Prevent IP Spoofing.

  • Open a Terminal and enter the following :
sudo vi /etc/host.conf
  • Add or edit the following lines :
order bind,hosts
nospoof on

8. Harden PHP for security.

  • Edit the php.ini file :
sudo vi /etc/php5/apache2/php.ini
  • Add or edit the following lines :
disable_functions = exec,system,shell_exec,passthru
register_globals = Off
expose_php = Off
magic_quotes_gpc = On

9. Web Application Firewall - ModSecurity.

10. Protect from DDOS (Denial of Service) attacks - ModEvasive

11. Scan logs and ban suspicious hosts - DenyHosts and Fail2Ban.

  • DenyHosts is a python program that automatically blocks SSH attacks by adding entries to /etc/hosts.deny. DenyHosts will also inform Linux administrators about offending hosts, attacked users and suspicious logins.
  • Open a Terminal and enter the following :
sudo apt-get install denyhosts
  • After installation edit the configuration file /etc/denyhosts.conf  and change the email, and other settings as required.
  • To edit the admin email settings open a terminal window and enter:
sudo vi /etc/denyhosts.conf
  • Change the following values as required on your server :
ADMIN_EMAIL = root@localhost
SMTP_HOST = localhost
SMTP_PORT = 25
#SMTP_USERNAME=foo
#SMTP_PASSWORD=bar
SMTP_FROM = DenyHosts nobody@localhost
#SYSLOG_REPORT=YES 
  • Fail2ban is more advanced than DenyHosts as it extends the log monitoring to other services including SSH, Apache, Courier, FTP, and more.
  • Fail2ban scans log files and bans IPs that show the malicious signs -- too many password failures, seeking for exploits, etc.
  • Generally Fail2Ban then used to update firewall rules to reject the IP addresses for a specified amount of time, although any arbitrary other action could also be configured.
  • Out of the box Fail2Ban comes with filters for various services (apache, courier, ftp, ssh, etc).
  • Open a Terminal and enter the following :
sudo apt-get install fail2ban
  • After installation edit the configuration file /etc/fail2ban/jail.local  and create the filter rules as required.
  • To edit the settings open a terminal window and enter:
sudo vi /etc/fail2ban/jail.conf
  • Activate all the services you would like fail2ban to monitor by changing enabled = false to enabled = true
  • For example if you would like to enable the SSH monitoring and banning jail, find the line below and change enabled from false to true. Thats it.
[ssh]

enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 3
  • If you would like to receive emails from Fail2Ban if hosts are banned change the following line to your email address.
destemail = root@localhost
  • and change the following line from :
action = %(action_)s
  • to:
action = %(action_mwl)s
  • You can also create rule filters for the various services that you would like fail2ban to monitor that is not supplied by default.
sudo vi /etc/fail2ban/jail.local
  • Good instructions on how to configure fail2ban and create the various filters can be found on HowtoForge - click here for an example
  • When done with the configuration of Fail2Ban restart the service with :
sudo /etc/init.d/fail2ban restart
  • You can also check the status with.
sudo fail2ban-client status

12. Intrusion Detection - PSAD.

  • Cipherdyne PSAD is a collection of three lightweight system daemons that run on Linux machines and analyze iptables log messages to detect port scans and other suspicious traffic.
  • Currently version 2.1 causes errors during install on Ubuntu 12.04, but apparently does work. Version 2.2 resolves these issues but is not yet available on the Ubuntu software repositories. It is recommended to manually compile and install version 2.2 from the source files available on theCiperdyne website
  • To install the latest version from the source files follow these instruction : How to install PSAD Intrusion Detection on Ubuntu 12.04 LTS server
  • OR install the older version from the Ubuntu software repositories, open a Terminal and enter the following :
sudo apt-get install psad

13. Check for rootkits - RKHunter and CHKRootKit.

  • Both RKHunter and CHKRootkit basically do the same thing - check your system for rootkits. No harm in using both.
  • Open a Terminal and enter the following :
sudo apt-get install rkhunter chkrootkit
  • To run chkrootkit open a terminal window and enter :
sudo chkrootkit
  • To update and run RKHunter. Open a Terminal and enter the following :
sudo rkhunter --update
sudo rkhunter --propupd
sudo rkhunter --check

14. Scan open ports - Nmap.

  • Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing.
  • Open a Terminal and enter the following :
sudo apt-get install nmap
  • Scan your system for open ports with :
nmap -v -sT localhost
  • SYN scanning with the following :
sudo nmap -v -sS localhost

15. Analyse system LOG files - LogWatch.

  • Logwatch is a customizable log analysis system. Logwatch parses through your system's logs and creates a report analyzing areas that you specify. Logwatch is easy to use and will work right out of the package on most systems.
  • Open a Terminal and enter the following :
sudo apt-get install logwatch libdate-manip-perl
  • To view logwatch output use less :
sudo logwatch | less
  • To email a logwatch report for the past 7 days to an email address, enter the following and replace mail@domain.com with the required email. :
sudo logwatch --mailto mail@domain.com --output mail --format html --range 'between -7 days and today' 

16. SELinux - Apparmor.

  • National Security Agency (NSA) has taken Linux to the next level with the introduction of Security-Enhanced Linux (SELinux). SELinux takes the existing GNU/Linux operating system and extends it with kernel and user-space modifications to make it bullet-proof.
  • More information can be found here. Ubuntu Server Guide - Apparmor
  • It is installed by default since Ubuntu 7.04. 
  • Open a Terminal and enter the following :
sudo apt-get install apparmor apparmor-profiles
  • Check to see if things are running :
sudo apparmor_status

17. Audit your system security - Tiger.

  • Tiger is a security tool that can be use both as a security audit and intrusion detection system.
  • Open a Terminal and enter the following :
sudo apt-get install tiger
  • To run tiger enter :
sudo tiger
  • All Tiger output can be found in the /var/log/tiger
  • To view the tiger security reports, open a Terminal and enter the following :
sudo less /var/log/tiger/security.report.*

martedì 31 luglio 2012

Example uses of the Linux Command zip

The following examples illustrate typical uses of the command zip for packaging a set of files into an "archive" file, also called "zip file". The command uses the standard zip file format. The archive files can therefore be used to tranfer files and directories between commonly used operating systems. 

 zip archivefile1 doc1 doc2 doc3
This command creates a file "archivefile1.zip" which contains a copy of the files doc1, doc2, and doc3, located in the current directory. 

 zip archivefile1 *
This command creates a file "archivefile1.zip" which contains a copy of all files in the current directory in compressed form. However, files whose name starts with a "." are not included. The extension ".zip" is added by the program. 

 zip archivefile1 .* *
This version includes the files that start with a dot. But subdirectories are still not included. 

 zip -r archivefile1 .
This copies the current directory, including all subdirectories into the archive file. 

 zip -r archivefile2 papers
This copies the directory "papers", located in the current directory, into "archivefile2.zip". 

 zip -r archivefile3 /home/joe/papers
This copies the directory "/home/joe/papers" into "archivefile3.zip". Since in this case the absolute path is given, it doesn't matter what the current directory is, except that the zip file will be created there.
The command unzip extracts the files from the zip file.
 unzip archivefile1.zip
This writes the files extracted from "archivefile1.zip" to the current directory. 

lunedì 23 luglio 2012

How to find a text file which contains a specific word inside (not in its name) in Ubuntu 12.04

I want to find a text file in my hard disk which contains a specific word. I want to use a graphic application. 


Prior to Ubuntu 12.04 I used to start in the dash an application, I think it was called "Search for file...", whose icon was a magnifying glass. 
In Ubuntu 12.04 :
Install gnome-search-tool.
Open Search for files select Select More Options and

enter image description here

giovedì 19 luglio 2012

How-To create a MySQL database and set privileges to a user


MySQL is a widely spread SQL database management system mainly used on LAMP (Linux/Apache/MySQL/PHP) projects.
In order to be able to use a database, one needs to create: a new database, give access permission to the database server to a database user and finally grant all right to that specific database to this user.
This tutorial will explain how to create a new database and give a user the appropriate grant permissions.
For the purpose of this tutorial, I will explain how to create a database and user for the music player Amarok. In order to index its music collection, Amarok quand use a mysql backend.
The requirement for this set up is to have access to a database. We are going to create a database called amarok which will be accessible from localhost to useramarok idetified by the password amarok....
Obviously, we need to to have a mysql server installed as well as amarok:
$ sudo apt-get install mysql-server amarok
On a default settings, mysql root user do not need a password to authenticate from localhost. In this case, ou can login as root on your mysql server using:
$ mysql -u root
If a password is required, use the extra switch -p:
$ mysql -u root -p
Enter password:
Now that you are logged in, we create a database:
mysql> create database amarokdb;
Query OK, 1 row affected (0.00 sec)
We allow user amarokuser to connect to the server from localhost using the password amarokpasswd:
mysql> grant usage on *.* to amarokuser@localhost identified by 'amarokpasswd';
Query OK, 0 rows affected (0.00 sec)
And finally we grant all privileges on the amarok database to this user:
mysql> grant all privileges on amarokdb.* to amarokuser@localhost ;
Query OK, 0 rows affected (0.00 sec)
And that's it. You can now check that you can connect to the MySQL server using this command:
$ mysql -u amarokuser -p'amarokpasswd' amarokdb
Your MySQL connection id is 12
Server version: 5.0.38-Ubuntu_0ubuntu1-log Ubuntu 7.04 distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

mercoledì 18 luglio 2012

8 Reasons To Use Prestashop For Your Ecommerce Store


Are you not using Prestashop for your e-commerce store? Here’s why you should.

Prestashop is a free, secure and open source e-commerce platform, packed with over 275+ features that will run on just about any web server.
If this isn’t enough to convince you to give it a shot, we’re going to run through 10 reasons to use Prestashop for your e-commerce store.
If you have never heard of Prestashop, you should visit our What is Prestashop? post for a quick run through of what you’re missing out on.
These reasons are by no means the only reasons to use Prestashop. Merchants needs will vary from store to store but I have yet to come across an e-commerce store that could not be run on Prestashop.

1. It’s Open source

Being open source means Prestashop means you can use, change and distribute in whichever way you see fit. If you’re an agency or designer looking for an e-commerce platform then Prestashop could be for you.
You could potentially, and quite easily, use Prestashop as a white label e-commerce platform for your client projects.
If however you’re a merchant, being open source means that there is a huge community of developers ready to help and aid you with your needs, as they actively work with the software and you don’t have to rely on the Prestashop team directly to aid you in your problems (often at a very large fee!).

2. Prestashop Themes and Modules

Prestashop Theme Example
Prestashop Themes and Modules allow you to completely change the look and feel of your store, often for free. You should see our Free Prestashop Themes and Templates post if you’d like to see whats out there.
If you’re willing to put in the time yourself to create something bespoke for your store, this is also very easy to do. Take a look at our Prestashop Theme inspiration gallery, or Matthew Morek’s Prestashop Module Boilerplate to get started creating Prestashop Themes and Modules right away.

3. Prestashop Overrides

Prestashop overrides allow developers to overwrite Prestashop’s core functionality, safe in the knowledge that their changes are not overwritten when Prestashop updates.
You can override Prestashop modules as well as Prestashop’s controllers and classes.
If you’re familiar with WordPress’ filter system this is quite similar.
As a merchant this might sound like nonsense to you, but it means that if a feature is not on your store, a developer can effectively create any feature you wish.

4. Prestashop 1.5

Though the current version, Prestashop 1.4 has been a big success including guest checkout, one page checkout and many more features, but Prestashop 1.5 is just around the corner.
Prestashop 1.5 will bring multi-stores, a better back office interface, processing orders through the admin interface and much more. We wrote about Prestashop 1.5′s upcoming features recently. Now looks like an exciting time to get onboard with using Prestashop.

5. Localisation

Prestashop Translations
Whether your store is in the UK, USA, Germany or the middle east, Prestashop supports your currency and language.
Translations by the Prestashop community and are available from the official website.
Prestashop supports multiple languages and currencies on one store, so your customers can then select their native currency. You need not have multiple stores for different regions, as Prestashop enables you to sell globally with ease.

6. SEO (Search Engine Optimisation)

Ranking well with Google can make or break your store. Luckily, Prestashop is very search engine friendly.
Prestashop features ‘pretty’ URL’s for all of your pages and products, allows custom meta information such as titles and keywords for each product, category and page, auto-generates Google XML Sitemapscanonical URLsand much more.
Your e-commerce store is optimised correctly for Google.

7. Payment Providers

Prestashop comes with a number of payment providers ‘out of the box’ such as PayPal and Google Checkout. If you’re looking for something a bit more specific, such as SagePay or Barclaycard EDPQ, then a number of payment modules available on the Prestashop Addons website covering just about every payment provider.

8. Security

Prestashop SecurityPrestashop is fully PCI Compliant and fully supports Secure Sockets Layer (SSL) certificates. Sensitive information such as passwords and cookies become encrypted and the Prestashop software encourages secure use, such as renaming your admin area’s URL to something more private, at every step of the way.
You can rest assured that Prestashop has put all the best security practices for e-commerce stores into practice on your behalf.

That’s it for now

Is there a particular reason that you use Prestashop for your store, or a reason that you’ve decided against it and instead opted for another e-commerce platform instead? Let us know in the comments below.

domenica 8 luglio 2012

How to install MySQL GUI Tools in 12.04?



  • Go to this page and download this packed :

  • Generic x86 Linux TAR (bundled dependencies) 5.0r12 23.5M
    1. extract the tar.gz with nautilus doble-click :
    enter image description here
    1. Open mysql-gui-tools-5.0 with nautilus an you will see :
    enter image description here
    1. The first time open a terminal an execute ./mysql-administrator
    enter image description here
    if you see one error like that just execute ./mysql-administrator --update-paths
    1. for second time an more just execute via nautilus
    enter image description here
    and voala! happy rocking...