The Perfect SpamSnake - Ubuntu 8.04 LTS - Page 02

1.3 Enable The root Account

After the reboot you can log in with your previously created username (e.g. administrator). Because we must run all the steps from this tutorial as root user, we must enable the root account now. Run

sudo passwd root

and give root a password. Afterwards we become root by running

su

1.4 Install vim-full (Optional)

I'll use vi as my text editor in this tutorial. The default vi program has some strange behaviour on Ubuntu and Debian; to fix this, we install vim-full:

apt-get install vim-full

(You don't have to do this if you use a different text editor such as joe or nano.)

1.5 Configure The Network

Because the Ubuntu installer has configured our system to get its network settings via DHCP, we have to change that now because a server should have a static IP address. Edit /etc/network/interfaces and adjust it to your needs (in this example setup I will use the IP address 192.168.0.100):

vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

Then restart your network:

/etc/init.d/networking restart

Then edit /etc/hosts. Make it look like this:

vi /etc/hosts

127.0.0.1       localhost.localdomain   localhost
192.168.0.100 server1.example.com server1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Now run

echo server1.example.com > /etc/hostname
/etc/init.d/hostname.sh start

Afterwards, run

hostname
hostname -f

Both should show server1.example.com now.

1.6 Edit /etc/apt/sources.list And Update Your Linux Installation

Edit /etc/apt/sources.list. Comment out or remove the installation CD from the file and make sure that the universe and multiverse repositories are enabled. It should look like this:

vi /etc/apt/sources.list

#
# deb cdrom:[Ubuntu-Server 8.04 _Hardy Heron_ - Release i386 (20080423.2)]/ hardy main restricted

#deb cdrom:[Ubuntu-Server 8.04 _Hardy Heron_ - Release i386 (20080423.2)]/ hardy main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.

deb http://de.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://de.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy universe
deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-updates multiverse

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://de.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository. This software is not part of Ubuntu, but is
## offered by Canonical and the respective vendors as a service to Ubuntu
## users.
# deb http://archive.canonical.com/ubuntu hardy partner
# deb-src http://archive.canonical.com/ubuntu hardy partner

deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted
deb http://security.ubuntu.com/ubuntu hardy-security universe
deb-src http://security.ubuntu.com/ubuntu hardy-security universe
deb http://security.ubuntu.com/ubuntu hardy-security multiverse
deb-src http://security.ubuntu.com/ubuntu hardy-security multiverse

Then run

apt-get update

to update the apt package database and

apt-get upgrade

to install the latest updates (if there are any).

1.7 Change The Default Shell

/bin/sh is a symlink to /bin/dash, however we need /bin/bash, not /bin/dash. Therefore we do this:

ln -sf /bin/bash /bin/sh

1.8 Disable AppArmor

AppArmor is a security extension (similar to SELinux) that should provide extended security. In my opinion you don't need it to configure a secure system, and it usually causes more problems than advantages (think of it after you have done a week of trouble-shooting because some service wasn't working as expected, and then you find out that everything was ok, only AppArmor was causing the problem).

We can disable it like this:

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove

1.9 Install Some Software

Now we install a few packages that are needed later on. Run

apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev lynx m4 make ncftp nmap openssl perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev g++ build-essential dpkg-dev db4.3-util vim bzip2 perl-doc libwww-perl libdbi-perl libconvert-binhex-perl libmail-spf-query-perl rblcheck libnet-ident-perl tnef pax libberkeleydb-perl unzoo arj lzop nomarch arc zoo libdb-file-lock-perl

(This command must go into one line!)

1.10 Install Unarj

cd /usr/src
wget http://http.us.debian.org/debian/pool/main/a/arj/unarj_3.10.21-2_all.deb
dpkg -i unarj_3.10.21-2_all.deb

1.11 Install Perl Modules(Pre-requisites)

Can be installed via perl -MCPAN or Webmin. I find that doing this through Webmin is better.

perl -MCPAN -e shell
install Module::Build
install Mail::SPF (Needed for SPF Checking)
install NetAddr::IP (Needed for SPF Checking)
install MLDBM::Sync this should also install MLDBM (Needed for MailWatch)

apt-get install libdbd-mysql-perl libapache-dbi-perl (Needed for MailWatch)

1.12 Webmin

apt-get install libauthen-pam-perl libio-pty-perl libmd5-perl libnet-ssleay-perl

Download latest webmin using the following command:

wget http://internap.dl.sourceforge.net/sourceforge/webadmin/webmin_1.410_all.deb

Now we have webmin_1.410_all.deb package; you need to install it using the following command:

sudo dpkg -i webmin_1.410_all.deb

If your server complains that there is some library it does not find, just run the following command

sudo apt-get install -f

You should now be able to login to Webmin at the URL https://localhost:10000/

1.13 Remove Programs

Now we also need to remove some programs, hopefully you don't need PCMCIA or printer support. This server will not need dial-up support either. You will not necessarily have all of these programs installed.

Uninstall the following software (all one line):

apt-get remove pcmciautils ubuntu-minimal pppoeconf ppp pppconfig

1.14 Cleaning up services

Some services might still linger even after uninstalling the daemons. First we need to backup inet.d:

cp -R /etc/init.d /etc/init.d.backup

Now we can stop all of the services that might be running which we don't need:

/etc/init.d/pcmciautils stop
update-rc.d -f pcmciautils remove

Disable all of the services we stopped:

update-inetd --disable time

update-inetd --disable daytime

update-inetd --disable echo

update-inetd --disable chargen

update-inetd --disable ident

update-inetd --disable discard

The last one may ask you a question regarding "multiple entries", answer yes (y).

Check that we got everything:

lsof -i | grep LISTEN

The only daemon you should see at this point is *:ssh and miniserv. You may have to run this again:

update-inetd --disable discard

If there are other programs shown, try rebooting and test again.


Copyright © 2008 Rocky
All Rights Reserved.

 

The Perfect SpamSnake - Ubuntu 8.04 LTS

Postfix w/Bayesian Filtering and Anti-Backscatter (Relay Recipients), Apache, Mysql, Bind, MailScanner (Spamassassin, ClamAV, Pyzor, Razor, DCC-Client), MailWatch, SPF Checks, FuzzyOcr, PDF/XLS/Phishing Sanesecurity Signatures, Postfix-GLD (Greylisting Optional), Logwatch Statistical Reporting (Optional), Outgoing Disclaimer with alterMIME (Optional)

Version 2.0
Author: Mohammed Alli

This tutorial shows how to set up an Ubuntu Hardy Heron (8.04 LTS) based server as a spamfilter in Gateway mode. In the end, you will have a SpamSnake Gateway which will relay clean emails to your MTA. You will also be able to view your incoming queue, train your SpamSnake and carry out a few more advanced operations via MailWatch.

I cannot offer any guarantees that this will work for you, the same way it’s working for me.

I will use the following software:

  • Web Server: Apache 2.2 with PHP 5.2.4 and Ruby
  • Database Server: MySQL 5.0
  • Mail Server: Postfix
  • DNS Server: BIND9
  • PHP: PHP5
  • MailScanner: MailScanner v4.68.8
  • MailWatch: MailWatch v1.0.4

Credit goes to the guys at HowToForge and the developers of MailScanner and MailWatch.

1 Requirements

To install such a system you will need the following:

1.1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.

1.2 The Base System

1. Insert your Ubuntu install CD into your system and boot from it. Select your language:


2. Select Install to the hard disk:

3. The installation starts, choose your language again:

4. Then select your location:

Choose a keyboard layout (you will be asked to press a few keys, and the installer will try to detect your keyboard layout based on the keys you pressed):

5. The installer checks the installation CD, your hardware, and configures the network with DHCP if there is a DHCP server in the network:



Enter the hostname. In this example, my system is called server1.example.com, so I enter server1:

6. Now you have to partition your hard disk. For simplicity's sake I will create one big partition (with the mount point /) and a little swap partition so I select Guided - use entire disk (of course, the partitioning is totally up to you - if you like, you can create more than just one big partition, and you can also use LVM):

Select the disk that you want to partition:

When you're finished, hit Yes when you're asked Write the changes to disks?:


Afterwards, your new partitions are being created and formatted.

7. Create a user, for example the user Administrator with the user name administrator (don't use the user name admin as it is a reserved name on Ubuntu 8.04):



8. The only item I select here is OpenSSH server so that I can immediately connect to the system with an SSH client such as PuTTY after the installation has finished:

9. The GRUB boot loader gets installed:

10. The base system installation is now finished. Remove the installation CD from the CD drive and hit Continue to reboot the system:



The Perfect SpamSnake - Ubuntu 8.04 LTS - Page 02
The Perfect SpamSnake - Ubuntu 8.04 LTS - Page 03

The Perfect SpamSnake - Ubuntu 8.04 LTS - Page 06
The Perfect SpamSnake - Ubuntu 8.04 LTS - Page 07


 

VMware Server On Ubuntu 8.04 Mini-Howto

Author : alex.revetchi

When upgrading from Ubuntu 7.10 to 8.04 my VMware server stopped working, this what I had to do to get it up and running:

Needed if upgrading VMware installation:

sudo ./vmware-install.pl

VMware wont compile with the new kernel, use this patch:

wget http://vmkernelnewbies.googlegroups.com/web/vmware-any-any-update-116.tgz




tar -zxf vmware-any-any-update-116.tgz
cd vmware-any-any-update-116

Apply the patch:

sudo ./runme.pl
sudo vmware-config.pl

VMware console wont run without this:

cp /lib/libgcc_s.so.1 /usr/lib/vmware/lib/libgcc_s.so.1/libgcc_s.so.1

You might need gcc3.4 as well.

Enjoy!

 

Web Based Project Management With Collabtive On Ubuntu 7.10 Server

Author : Shakey

Project management is becoming an increasingly important part of the Sys Admin's life. While Microsoft Project seems to be the standard project management tool used in most environments that I have worked in, it can sometimes be nice to have such tools web based so that multiple users can share information. This is where tools such as Collabtive come in. Collabtive is a web based project management tool that supports everything that you need to plan out and complete your projects.

These tools include milestones, time tracking, tasks and task lists, all presented in a multi language environment. Currently German, English and French are all supported. The web interface itself is intuitive, functional and attractive all at the same time. You can see for yourself though at their online demo - Collabtive online demo

If after having tried the demo, you decide that this is the right tool for you, then this guide should help you to implement Collabtive on your own Ubuntu 7.10 server. This guide is based on the base LAMP install that comes packaged with Ubuntu 7.10 server, but should work equally as well on any Ubuntu LAMP server. The installation is fairly straight forward, so let's begin.

The base Ubuntu installation

As I mentioned earlier, this guide is based on the base LAMP installation included with Ubuntu. The only things that I did during the installation was to assign a static IP address and choose the LAMP and OpenSSH Server options when prompted. Once you have the base system installed along with the LAMP and OpenSSH server, you are ready to move on. I will assume from this point that you are either working at the command line on your server or using an SSH client such as PuTTY.

Update your server

The first step we need to take is to make sure that your server is up to date. Issue the following command to edit your sources.list file:

sudo nano /etc/apt/sources.list

Now that your sources.list file is open, you will need to edit out the cdrom from your updates list. Find the following line in your sources.list file:

deb cdrom:[Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)]/ gutsy main restricted

Now comment it out as shown below:

# deb cdrom:[Ubuntu-Server 7.10 _Gutsy Gibbon_ - Release i386 (20071016)]/ gutsy main restricted

Once you have made the necessary change, you can save the file by pressing "CTRL-O" on your keyboard and can exit the editor by pressing "CTRL-X".

With that done, you can now proceed to update your system. We will also be installing unzip for use later in the guide. Issue these commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install unzip

Obtain Collabtive and prepare for the installation

In this step, you will be creating the directory in which Collabtive will be installed, obtaining the Collabtive code itself and setting up permissions. Issue the following commands:

cd /var/www/
sudo mkdir collabtive
cd collabtive/
sudo wget http://superb-west.dl.sourceforge.net/sourceforge/collabtive/collabtive0-4-5.zip
sudo unzip collabtive0-4-5.zip
sudo rm collabtive0-4-5.zip
sudo chmod -R 757 templates_c/
sudo chmod -R 757 files/
sudo chmod 757 config.php

Create the Collabtive database and database user

This step will help you to create a database for Collabtive in MySQL, as well as the user under which access will be granted. To enter the MySQL environment, issue the root login request with this command:

mysql -uroot -p

You will now be prompted for your root MySQL password. After entering it, issue the following commands to create your database and the database user. Please note that you can change the username and password to meet your needs.

create database collabtive;
grant all on collabtive.* to collabuser;
grant all on collabtive.* to collabuser@localhost;
set password for collabuser=password('collabPW');
set password for collabuser@localhost=password('collabPW');
exit

The web setup phase

It is now time to begin the web setup phase of the installation process (almost done). Point your web browser to the URL shown below (adjusting of course, for the local IP address of your server):

http://Server IP address/collabtive/install.php

You should now be greeted with the first page of the web setup. On this page, you can change your language to German, English or French. You can also check to ensure that conditions for the installation are ready to proceed (see the screen shot below) and enter your database information. If you followed the guide above, then the information that you will need is as follows:

Database host: localhost
Database name: collabtive
Database user: collabuser
Database password: collabPW

Collabtive Step 1

If everything appears alright here, then you can click on "continue" to move forward to step number 2. In this step, you will be creating your admin user. It is fairly straight forward, simply enter the username and password that you wish to use and click on continue. See the image below for reference.

Collabtive Step 2

You should now be greeted with a screen letting you know that the installation was successful, as shown in this image.

Collabtive Step 3

If you see anything other than message, then you may want to retrace your steps and make sure that you did not miss something. If you do see the above image though, you can now safely remove the install.php file for security purposes by using the following command:

sudo rm /var/www/collabtive/install.php

Now, you may click on the "Login" link shown above to be taken to the admin login. If all has gone well, then you should now be prompted with a login request (see the image below). This will the admin user that you created in step #2 of the web installation.

Collabtive Step 4

Enter your credentials and click on the "Login" button. You should now be presented with the web interface for Collabtive and ready to begin your first project. While I couldn't find any documentation on the usage of Collabtive, it is fairly straight forward, if you are familiar with project management. If you should run into problems though, they do have a forum that has a lot of good information in it. The forums are located at - Collabtive Forums.

Links


 

Using vi key bindings in bash and zsh

Author : Vincent Danen, ZDNet Asia

When making command-line changes, you can choose a style that makes sense and makes the use of the command line faster and more efficient.


By default, most shells use emacs-style key bindings for command-line editing and modification.

For users of vi or vim, however, you can instead configure shells to use vi key bindings instead.

This is done by editing ~/.bashrc in the case of bash, or ~/.zshrc in zsh and adding:

set -o vi

in bash, and the following for zsh:

bindkey -v

Once you have saved either ~/.bashrc or ~/.zshrc, exit the shell and open a new terminal.

By default, you will be in insert mode, which means that you type as you normally would.

Commands like [Ctrl]A or [Ctrl]E no longer work, however.

To get into command mode, press [ESC] (as you would in vim) and use vi key commands to navigate the command line, such as $ to go the end of the line or 0 to go to the beginning of the line.

From that point, you can use other vi commands:

  • b to go back one word
  • 2b to go back two words
  • dw to delete a word
  • dd to delete the entire line
  • d$ to delete from the current cursor position to the end of the line
  • d0 to delete from the current cursor position to the beginning of the line
  • w to go forward one word, and so forth

To return to insert mode, simply type i, as you would in vi, and you can edit the command line as you normally would.

If you are more familiar with vim than emacs, using vi key bindings in your shell makes a lot of sense and will make working in the shell much easier as you will be using edit commands that you are already familiar with.

If you use emacs more often, leave the defaults as they are to use the various commands you would normally use in emacs.

On the other hand, if you use neither, choose a style that makes the most sense and makes using the command line faster and more efficient.

 

How To Install mod_security/mod_security2 On SuSE Linux Enterprise Server 10 (SLES10)

Author : elconas
Introduction

The Apache module mod_security is a very powerful security module. Combined with predefined rules, you can close many security wholes on your server, opened by bad written php or perl apps.

Unfortunately mod_security is not part of the SLES10 distribution. To install mod_security to have to install some 3rd party modules. This guide helps you to install mod_security on SLES10. It also helps you to remove the module, by building RPM packages you can easily uninstall.






Install Apache2

First of all you have to install apache2. This is very simple with the following command.

yast2 -i apache2

Install requried build packages

Some modules are required to build the mod_security module. Install the following packages:

yast2 -i libxml2-devel pcre-devel apache2-devel curl-devel gcc gcc-c++

Apache2-devel is required for apxs2. curl-devel is optional.

Get and Install checkinstall (for packaging)

To keep track of installed software and enable the user to uninstall and update software, checkinstall can build RPM, DEBIAN (DEB) and Slackware packages. Instead of executing "make install" just run "checkinstall" and checkinstall catches all files, that would be installed by "make install".

Get checkinstall from http://www.asic-linux.com.mx/~izto/checkinstall/download.php.

wget http://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.1.tgz
make
make install
checkinstall
cp /usr/src/packages/RPMS/i386/checkinstall-1.6.1-1.i386.rpm .
rpm -ivh checkinstall-1.6.1-1.i386.rpm

Get and Install liblua

The LUA programming language is used by mod_security for configuration. You must compile LUA as shared module.

Get LUA from http://www.lua.org/ftp/lua-5.1.3.tar.gz.

wget http://www.lua.org/ftp/lua-5.1.3.tar.gz
tar -zxvf lua-5.1.3.tar.gz
cd lua-5.1.3
make linux
checkinstall

[...]
1 - Summary: [ The LUA programming language ]
2 - Name: [ lua ]
3 - Version: [ 5.1.3 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Development/Languages/Lua ]
7 - Architecture: [ i386 ]
8 - Source location: [ http://www.lua.org/ftp/lua-5.1.3.tar.gz ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
11 - Provides: [ lua ]
[...]

cp /usr/src/packages/RPMS/i386/lua-5.1.3-1.i386.rpm ..
rpm -ivh ../lua-5.1.3-1.i386.rpm

Now you have to build a shared library from the liblua archive.

cd /usr/local/lib
gcc -shared -o liblua.5.1.3.so /usr/local/lib/liblua.a
ln -s liblua.5.1.3.so liblua.so

Get and Install mod_security

Get mod_security from http://www.modsecurity.org/download/direct.html.

Documentation about the installation can be found here: http://www.modsecurity.org/documentation/index.html.

cd modsecurity-apache_2.5.2
cd apache2
./configure
make
checkinstall

...
1 - Summary: [ mod_security application level firewall ]
2 - Name: [ apache2-mod_security ]
3 - Version: [ 2.5.2 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ Productivity/Networking/Web/Servers ]
7 - Architecture: [ i386 ]
8 - Source location: [ http://www.modsecurity.org/download/ ]
9 - Alternate source location: [ ]
10 - Requires: [ apache2 libxml2 ]
11 - Provides: [ mod_security ]

cp /usr/src/packages/RPMS/i386/apache2-mod_security-2.5.2-1.i386.rpm ../../
rpm -ivh ../../apache2-mod_security-2.5.2-1.i386.rpm

Configure Apache2 for mod_security

# /etc/apache2/conf.d/mod_security.conf
LoadFile /usr/lib/libxml2.so
LoadFile /usr/local/lib/liblua.so
LoadModule security2_module /usr/lib/apache2/mod_security2.so
Include modsecurity/*.conf
LoadModule unique_id_module /usr/lib/apache2/mod_unique_id.so

Extract and Configure Core Rules

Get the core rules from http://www.modsecurity.org/download/modsecurity-core-rules_2.5-1.6.0.tar.gz.

cd /etc/apache2
mkdir modsecurity
cd modsecurity
tar -zxvf ../modsecurity-core-rules_2.5-1.6.0.tar.gz

Modify modsecurity_crs_10_config.conf to meet the location of your config files:

vi modsecurity_crs_10_config.conf
SecAuditLog=...
SecDebugLog=...

Restart Apache and Test your Webpage

First restart apache to get the current configuration:

rcapache restart

To test the installation, write a simple (insecure) PHP script like this:

file $text=$_GET['file'];
echo "Content of File $text";
echo `cat $text`;
?>

Then access it to try opening insecure files:

http://ip.of.your.server.de/index.php?file=/etc/passwd

You should get ERROR 501 in your browser and the SecAuditLog file should show:

[...]
GET /index.php?file=/etc/passwd HTTP/1.1 ...
[...]
Message: Access denied with code 501 (phase 2). Pattern match "(?:\b(?:\.(?:ht(?:access|passwd|group
)|www_?acl)|global\.asa|httpd\.conf|boot\.ini)\b|\/etc\/)" at ARGS:file. [file "/etc/apache2/modsecu
rity/modsecurity_crs_40_generic_attacks.conf"] [line "114"] [id "950005"] [msg "Remote File Access A
ttempt"] [data "/etc/"] [severity "CRITICAL"] [tag "WEB_ATTACK/FILE_INJECTION"]

Caveats

  • When accessing your server via IP, a rule in modsecurity_crs_21_protocol_anomalies.conf denies this. Edit the file and look for "Check that the host header is not an IP address".

Links and References


 

Securely delete files with shred

Author : Vincent Danen, ZDNet Asia

Scrub your data using the shred command for files that contain sensitive information, so that they cannot be recovered later with data retrieval tools.


There are two utilities on a typical Linux box that can be used to delete files. Most users are familiar with the rm command. Most of the time, this command is sufficient for routine deletion, but for files that contain sensitive data, you might need to scrub them so that they cannot be recovered later with other data retrieval tools.

To delete files with sensitive content, rm is not sufficient. Instead, consider using the shred command, which not only deletes a file, but deletes it in such a way that it cannot be recovered. Shred overwrites the file multiple times with garbage prior to deleting it, ensuring that if anything does get retrieved, it isn't your top-secret data.

For instance:

$ echo "this is private data" >private.txt
$ cat private.txt
this is private data
$ ls -l private.txt
-rw-r--r-- 1 vdanen vdanen 21 Mar  4 09:36 private.txt

To illustrate how shred works, call it without any command-line options so that the garbage in the file can be viewed:

$ shred private.txt
$ cat private.txt
?9?-?w?K?=???l;b8SƉ?b???????@,?18!??DM??P?
...
$ ls -l private.txt
-rw-r--r-- 1 vdanen vdanen 4096 Mar  4 09:36
private.txt

The rest of the output is removed as it is binary gibberish. You can also see the file size has changed.

To delete the file after overwriting it with garbage, use the -u option. To see what shred is actually doing, give it the verbose -v option:

$ shred -u -v private.txt
shred: private.txt: pass 1/25 (random)...
shred: private.txt: pass 2/25 (cccccc)...
shred: private.txt: pass 3/25 (111111)...
shred: private.txt: pass 4/25 (000000)...
shred: private.txt: pass 5/25 (999999)...
shred: private.txt: pass 6/25 (aaaaaa)...
shred: private.txt: pass 7/25 (924924)...
shred: private.txt: pass 8/25 (b6db6d)...
shred: private.txt: pass 9/25 (6db6db)...
shred: private.txt: pass 10/25 (888888)...
shred: private.txt: pass 11/25 (492492)...
shred: private.txt: pass 12/25 (db6db6)...
shred: private.txt: pass 13/25 (random)...
shred: private.txt: pass 14/25 (ffffff)...
shred: private.txt: pass 15/25 (bbbbbb)...
shred: private.txt: pass 16/25 (777777)...
shred: private.txt: pass 18/25 (dddddd)...
shred: private.txt: pass 19/25 (333333)...
shred: private.txt: pass 20/25 (555555)...
shred: private.txt: pass 21/25 (222222)...
shred: private.txt: pass 22/25 (eeeeee)...
shred: private.txt: pass 23/25 (666666)...
shred: private.txt: pass 24/25 (249249)...
shred: private.txt: pass 25/25 (random)...
shred: private.txt: removing
shred: private.txt: renamed to 00000000000
shred: 00000000000: renamed to 0000000000
shred: 0000000000: renamed to 000000000
shred: 000000000: renamed to 00000000
shred: 00000000: renamed to 0000000
shred: 0000000: renamed to 000000
shred: 000000: renamed to 00000
shred: 00000: renamed to 0000
shred: 0000: renamed to 000
shred: 000: renamed to 00
shred: 00: renamed to 0
shred: private.txt: removed

As you can see, shred overwrites the file 25 times with garbage. After this, it renames the file 11 times before deleting it.

Shred can also be used to overwrite entire disks instead of just files. If you wished to overwrite the contents of an entire hard drive, a process which would definitely take a fair amount of time, use:

# shred -u -n 30 /dev/hda

This will overwrite the data on the drive with garbage using 30 passes. The drive will need to be re-formatted after this as even the filesystem structure will be destroyed.

 

Monitoring UPS Power Status Using Network UPS Tools (NUT) 2.2.0 on Multiple OpenSuSE 10.3 Servers

Author : kian

Network UPS Tools is a collection of programs which provide a common interface for monitoring and administering UPS hardware.

The primary goal of the Network UPS Tools (NUT) project is to provide reliable monitoring of UPS hardware and ensure safe shutdowns of the systems which are connected.

This is a developing project to monitor a large assortment of UPS hardware. Many models have ports on the back to allow other devices to check the status. If it gives basic information about the power and battery status, it can probably be supported without too much difficulty. More advanced features on the higher-end models are also supported to allow tracking of values over time such as temperature and voltage.

Network communications are used so that multiple systems can monitor a single physical UPS and shut down together if necessary without any special "sharing hardware" on the UPS itself.

Pre-installation

Before you have everything up and running on the server, plug the UPS to a power outlet and connect the signal cable (serial or USB) to the server that will run upsd. Do not connect any server power cables to the outlet on the UPS until you feel that you are confident with the working of NUT and how it behaves with your hardware. It is often advised that you use a dummy load such as a lamp when testing the UPS. This will also show you when the UPS delivers power and when it is off, giving you the opportunity to experiment safely and gain confidence with the commands in a way you can't do once you hook up a production server to the UPS.




Installation

Install the nut RPM package. If you use YaST2, required packages will automatically be added. From the command line, you can use

yast2 -i nut

as root.

In OpenSuSE 10.3, you will get nut 2.2.0 installed.

This will place all the necessary binaries in your path and a set of skeleton configuration files. You will have to edit the files as root in order to define your UPS hardware

Configuration

Configuration of a locally connected UPS

Either open a root shell, or use e.g.

sudo vi

to edit the configuration files.

In the file /etc/ups/ups.conf you have a dummy section with default values that looks like this:

[myups]
driver = undefined
port = /dev/undefined
desc = "Local UPS"

Edit the file and set the driver to point to the correct driver for your UPS, the port to where you connected the signal cable and add a description. See /usr/share/nut/driver.list for a list of supported brands and models.

Here is my entry for an APC SmartUPS 1400 connected to the serial port.

[apc_smartups_1400]
driver = apcsmart
port = /dev/ttyS0
desc = "APC SmartUPS 1400"

You have to modify the /etc/ups/upsd.users file to configure users and permissions. The passwords are automatically generated during installation, so you can leave them set to these random values if you like. If you want to use a password that you can remember, edit the file. There are two entries in the default file, I also added an admin user so I can calibrate and test the UPS from the command line.

Note that these users can only connect from localhost, so for now security is not a big issue here. With remote slaves, you should use a more advanced password than what I have in these examples.

Here are the three users defined in the /etc/ups/upsd.users file.

[upsmaster]
password = masterpass123
allowfrom = localhost
upsmon master
[upsslave]
password = slavepass123
allowfrom = localhost
upsmon slave
[upsadmin]
password = upspass
allowfrom = localhost
actions = SET
instcmds = ALL

The upsd daemon only polls the UPS, you need other programs to check upsd for status. Edit their config files to reflect the new name of the UPS and the login and password.

/etc/ups/upsmon.conf

# MONITOR myups@localhost 1 upsmaster 67fc9377aa master
MONITOR apc_smartups_1400@localhost 1 upsmaster masterpass123 master

I also prefer to get a "wall" notice when power is restored in case I work remotely and there is a short power failure. Change the line:

NOTIFYFLAG ONLINE   SYSLOG

to

NOTIFYFLAG ONLINE   SYSLOG+WALL

in the /etc/ups/upsmon.conf file.

/etc/ups/hosts.conf is only for the included CGI programs, but you can add the correct information here as well

/etc/ups/hosts.conf

# MONITOR myups@localhost "Local UPS"
MONITOR apc_smartups_1400@localhost "APC SmartUPS 1400"

Now we can finally start all of these programs:

rcupsd start

linux:~ # rcupsd start
Starting NUT UPS drivers done
Starting NUT UPS server done
Starting NUT UPS monitor done

Check that you are up and running and that you can read the stored values from the UPS. First list available devices with

upsc -l

... then read all values with:

upsc

linux:~ # upsc -l
apc_smartups_1400
linux:~ # upsc apc_smartups_1400
battery.alarm.threshold: 0
battery.charge: 100.0
battery.charge.restart: 00
[...]

Testing

Before you connect your server to the power, test a realistic power failure unplugging the power cord to the UPS unit. It should fail over to battery and you get a warning message. If you are logged in and running KDE you get a popup from KWrited with a message such as:

Broadcast Message from upsd@linux
(somewhere) at 22:51
UPS apc_smartups_1400@localhost on battery

Plug the cable back in and observe the reassuring messages that power has been restored.

Broadcast Message from upsd@linux
(somewhere) at 22:51
UPS apc_smartups_1400@localhost on line power

If this works, you can shut your server down and connect the power cord to the UPS. In case of a power failure, you will get the messages you saw during testing. Once the battery charge is so low that the UPS sends a "low battery" signal, NUT will shut down the server. You may be able to set this threshold in the UPS registers, or you will have to script something that does a

shutdown -h -t

(system halt after ) as soon as the UPS is on battery, and then does a

shutdown -c

(cancel shutdown) when the UPS is back on line power. Not all UPS devices will send this "restored" message, though. This is where you just have to test and customize.

Running your equipment on UPS

So your server is now running on battery power until the batteries run out. You may want to once actually run the server until the batteries fail, just to have an idea of how much battery time you have. Most UPS devices can show you the load and a battery charge percentage. UPSes are great when you are working on something really important and there is a short power surge or brownout, and in case of a long lasting blackout you can get the machine to suspend, hibernate or shut down when batteries are low.

If you set your BIOS to start the machine automatically when it starts to received power, it will automatically boot when power is restored. In case of recurrent power failures, you don't want to keep a server running and drain the batteries. Just think of a UPS as a unit that protects you from power surges and spikes, and can provide you with a clean shutdown in case of power failure. Don't run a server on battery just because you can. Batteries in a UPS are not meant to be drained, and when power is restored they normally take a few hours to restore full charge. You don't want to run the servers without a safety net right after a blackout - shut servers down with plenty of battery power left and save it for the rough time period just after power restore when every appliance in the entire city starts up simultaneously and starts to guzzle power. For the same reason, limit what you keep on UPS to important servers. Don't forget to add necessary supporting hardware such as network equipment, KVMs and monitors needed to operate the servers during power failure. Avoid running printers and most workstations on UPS power. Keep emergency light in the server room so you can work there when the normal lights are out. If you keep servers running for a while with your own power source (such as a generator), you may even want to keep HVAC on the same power to avoid overheating the room.

Also remember that when all equipment starts to draw poewr at once - servers and workstations all simultaneously boot, all monitors and lights light up and laser printers start to warm up - you must expect to blow a fuse or two. Which then prolongs your blackout. Make sure all non-critical equipment is shut off during power failures and manually switched on again afterwards.

Remote clients

Allowing remote clients

Now that you know the local UPS is working as it should - keeping the server running on power and notifying the OS via serial port or USB - you may want to connect more servers to the rest of the power outlets. However, there is only one USB or serial cable. This is when you need the NUT upsd daemon on the machine with the serial cable to notify the other servers via the network.

Start by editing the /etc/ups/upsd.conf to allow clients. Here the entire subnet is allowed, you may want to make it more fine-grained and only include specific IPs.

ACL all 0.0.0.0/0
ACL localhost 127.0.0.1/32
ACL upsnet 192.168.1.0/24
ACCEPT localhost
ACCEPT upsnet
REJECT all

Now allow the slave to connect from this network in /etc/ups/upsd.users:

[upsslave]
password = slavepass123
allowfrom = localhost upsnet
upsmon slave

Restart the upsd daemond again to pick up the changes.

rcupsd restart

linux:~ # rcupsd restart
Shutting down NUT UPS monitor done
Shutting down NUT UPS server done
Shutting down NUT UPS drivers. done
Starting NUT UPS drivers done
Starting NUT UPS server done
Starting NUT UPS monitor done

Or better, reload the configuration, this is much faster than restarting the daemons when you only need to reconfigure any setting except for the driver settings which demands a service restart as above.

rcupsd reload

linux:~ # rcupsd reload
Reload service NUT UPS (excluding upsdrvctl) done

And allow the clients through the firewall (OpenSuSE by default runs an iptables firewall called SuSEfirewall). upsd listens on TCP port 3493, and by default listens on all interfaces.

Create a SuSEfirewall2 service definition, since the RPM didn't include one. Make a new file named /etc/sysconfig/SuSEfirewall2.d/services/upsd . with this content:

# Service description for upsd, the UPS daemon from NUT
# (Network UPS Tools)
#
## Name: NUT upsd
## Description: Allows remote monitoring of UPS power status
# space separated list of allowed TCP ports
TCP="3493"
# space separated list of allowed UDP ports
UDP=""
# space separated list of allowed RPC services
RPC=""
# space separated list of allowed IP protocols
IP=""
# space separated list of allowed UDP broadcast ports
BROADCAST=""

Now start

YaST

as root and choose "Security and Users" -> "Firewall". Select the correct network and choose NUT upsd in the drop-down list. Add the service and click the Next button. This adds upsd to the list of allowed services in the FW_CONFIGURATIONS_EXT variable in the /etc/sysconfig/SuSEfirewall2 configuration script. Port 3493 is now allowed through the iptables firewall.

Configuring remote clients

Install nut on a remote machine, this one is called linux64.

Comment out everything in /etc/ups/ups.conf since we don't have a local UPS attached:

#[myups]
# driver = undefined
# port = /dev/undefined
# desc = "Local UPS"

Edit /etc/ups/upsmon.conf to monitor the server where the UPS is connected:

#MONITOR myups@localhost 1 upsmaster 04fb251a3f master
MONITOR apc_smartups_1400@linux 1 upsslave slavepass123 slave

Add the UPS server to /etc/ups/hosts.conf:

#MONITOR myups@localhost "Local UPS"
MONITOR apc_smartups_1400@linux "APC SmartUPS 1400"

Now start the upsd service, which will ignore the actual upsd and UPS driver since they are unconfigured, and only start upsmon.

rcupsd start

linux64:~ # rcupsd start
Starting NUT UPS monitor done

Check that the connection is working, and that you can read the status values of the remote UPS server.

upsc apc_smartups_1400@linux

linux64:~ # upsc apc_smartups_1400@linux
battery.alarm.threshold: 0
battery.charge: 094.0
battery.charge.restart: 00
[...]

Test the UPS again, and check that the new client also picks up the message

Broadcast Message from upsd@linux64
(somewhere) at 0:13 ...
UPS apc_smartups_1400@linux on battery

Connect the power cable for this server to the UPS, and you now have two servers protected from blackouts and they are both monitoring power status.

References


Copyright (c) 2008 Kian Spongsveen
Permission is granted to copy, distribute and/or modify the content of
this page under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is available at http://www.gnu.org/licenses/fdl.html

 

MySQL Backups Using ZRM For MySQL 2.0

Author : Paddy Sreenivasan

Zmanda Recovery Manager (ZRM) for MySQL simplifies life of a database administrator who needs an easy to use yet flexible and robust backup and recovery solution for MySQL server. Significant features are:

* Schedule full and incremental logical or raw backups of your MySQL database
* Centralized backup management
* Perform backup that is the best match for your storage engine and your MySQL configuration
* Get e-mail notification about status of your backups
* Monitor and obtain reports about your backups (including RSS feeds)
* Verify your backup images
* Compress and encrypt your backup images
* Implement Site or Application specific backup policies
* Recover database easily to any point in time or to any particular database event
* Custom plugins to tailor MySQL backups to your environment
* MySQL backup using Linux LVM and Solaris ZFS snapshots

Release 2.0 of the community project was released last week. It can be downloaded from Zmanda downloads page. It supports all Linux and Solaris distributions. The documentation is available on ZRM wiki. ZRM forums can be used to get questions answered about the project.

This example assumes that the ZRM server and MySQL server are the same machine. We are backing up MySQL database



myisamnetflix

to the same machine running Ubuntu 7.04.

ZRM For MySQL Installation

* Installation has to be done as super user.

* ZRM for MySQL requires perl 5.8.7 or later. Ubuntu 7.04 already has perl 5.8.8 installed.

* Install perl-DBD and perl-XML-parser modules

# apt-get install libxml-parser-perl libdbd-mysql-perl

* Download ZRM for MySQL debian packages from Zmanda downloads page.

* Install ZRM for MySQL (ZRM server package is sufficient because MySQL server and ZRM server are the same machine).

# dpkg -i mysql-zrm_2.0_all.deb

Selecting previously deselected package mysql-zrm.
(Reading database ... 108342 files and directories currently installed.)
Unpacking mysql-zrm (from mysql-zrm_2.0_all.deb) ...
Setting up mysql-zrm (2.0) ...
Updating ownership of previously backedup data sets

MySQL Server Configuration

* Check to see if MySQL server is running. If MySQL server is not installed, please install "mysql-server" using "apt-get" command. Update the "root" MySQL server with a password using mysqladmin command (mysqladmin --user root password boot12). We are using "boot12" as the root password. This user will be used for doing MySQL backups and restores. It is better to user a specific user with minimal privileges to do MySQL backups instead of using "root" MySQL user.

* The MySQL server has to run as "mysql" user and "mysql" OS user should belong to "mysql" group. The default installation of ZRM for MySQL requires MySQL server to run as "mysql" user.

* "ps" output shows mysql server is running using the default MySQL port

mysql 22034 21995 0 14:38 pts/2 00:00:09 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock

* Enable binary logging on the MySQL server. Binary logging must be enabled to do incremental backups of the MySQL server.

* Edit /etc/mysql/my.cnf configuration file. Add "log-bin" in mysqld section.

 [mysqld]
log-bin

* We have mysql database "myisamnetflix" that contains two tables. We will be backing this database. This database uses MyISAM storage engine:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| myisamnetflix |
| mysql |
+--------------------+
3 rows in set (0.00 sec)

mysql> use myisamnetflix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------------+
| Tables_in_myisamnetflix |
+-------------------------+
| MovieID |
| MovieRatings |
+-------------------------+
2 rows in set (0.00 sec)

mysql> select count(*) from MovieID;
+----------+
| count(*) |
+----------+
| 17770 |
+----------+

* MySQL client commands are installed in /usr/bin/ directory. If they are not, accordingly configure the client command location and binary log location in mysql-zrm.conf.

ZRM Configuration

* This should be done as mysql user:

$ id

uid=1002(mysql) gid=1001(mysql) groups=1001(mysql)

* Create the backup set directory. The backup set is called "netflix".

$ mkdir /etc/mysql-zrm/netflix

* Create mysql-zrm.conf configuration file. Backup compression is enabled and "myisamnetflix" database is being backed up. The location of MySQL binary logs are also specified ("mysql-binlog-path").

$ cat /etc/mysql-zrm/netflix/mysql-zrm.conf

 host="localhost"
databases="myisamnetflix"
password="boot12"
user="root"
compress=1
mysql-binlog-path="/var/log/mysql"

Perform ZRM Backups

* This should be done as "mysql" user.

* Perform full backup of the database immediately using "mysql-zrm-scheduler".

$ mysql-zrm-scheduler --now --backup-set netflix --backup-level 0

schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
backup:INFO: ZRM for MySQL Community Edition - version 2.0
netflix:backup:INFO: START OF BACKUP
netflix:backup:INFO: PHASE START: Initialization
netflix:backup:INFO: backup-set=netflix
netflix:backup:INFO: backup-date=20080326161652
netflix:backup:INFO: mysql-server-os=Linux/Unix
netflix:backup:INFO: host=localhost
netflix:backup:INFO: backup-date-epoch=1206573412
netflix:backup:INFO: mysql-zrm-version=ZRM for MySQL Community Edition - version 2.0
netflix:backup:INFO: mysql-version=5.0.38-Ubuntu_0ubuntu1.4-log
netflix:backup:INFO: backup-directory=/var/lib/mysql-zrm/netflix/20080326161652
netflix:backup:INFO: backup-level=0
netflix:backup:INFO: backup-mode=raw
netflix:backup:INFO: PHASE END: Initialization
netflix:backup:INFO: PHASE START: Running pre backup plugin
netflix:backup:INFO: PHASE END: Running pre backup plugin
netflix:backup:INFO: PHASE START: Flushing logs
netflix:backup:INFO: PHASE END: Flushing logs
netflix:backup:INFO: PHASE START: Find table type
netflix:backup:INFO: PHASE END: Find table type
netflix:backup:INFO: PHASE START: Creating raw backup
netflix:backup:INFO: raw-databases=myisamnetflix
netflix:backup:INFO: PHASE END: Creating raw backup
netflix:backup:INFO: PHASE START: Calculating backup size & checksums
netflix:backup:INFO: next-binlog=mysql-bin.000009
netflix:backup:INFO: backup-size=122.27 MB
netflix:backup:INFO: PHASE END: Calculating backup size & checksums
netflix:backup:INFO: PHASE START: Compression/Encryption
netflix:backup:INFO: compress=
netflix:backup:INFO: backup-size-compressed=37.65 MB
netflix:backup:INFO: PHASE END: Compression/Encryption
netflix:backup:INFO: read-locks-time=00:00:01
netflix:backup:INFO: flush-logs-time=00:00:00
netflix:backup:INFO: compress-encrypt-time=00:02:20
netflix:backup:INFO: backup-time=00:00:15
netflix:backup:INFO: backup-status=Backup succeeded
netflix:backup:INFO: Backup succeeded
netflix:backup:INFO: PHASE START: Running post backup plugin
netflix:backup:INFO: PHASE END: Running post backup plugin
netflix:backup:INFO: PHASE START: Mailing backup report
netflix:backup:INFO: PHASE END: Mailing backup report
netflix:backup:INFO: PHASE START: Cleanup
netflix:backup:INFO: PHASE END: Cleanup
netflix:backup:INFO: END OF BACKUP
/usr/bin/mysql-zrm started successfully

* Delete some entries from the "myisamnetflix" database (so that we can do incremental backup of the database)
mysql> use myisamnetflix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> delete from MovieID where MovieTitle = "Alien Hunter";
Query OK, 1 rows affected (0.01 sec)

* Perform incremental backup of the backup set.

$ mysql-zrm-scheduler --now --backup-set netflix --backup-level 1

schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
backup:INFO: ZRM for MySQL Community Edition - version 2.0
netflix:backup:INFO: START OF BACKUP
netflix:backup:INFO: PHASE START: Initialization
netflix:backup:INFO: backup-set=netflix
netflix:backup:INFO: backup-date=20080326164433
netflix:backup:INFO: mysql-server-os=Linux/Unix
netflix:backup:INFO: host=localhost
netflix:backup:INFO: backup-date-epoch=1206575073
netflix:backup:INFO: mysql-zrm-version=ZRM for MySQL Community Edition - version 2.0
netflix:backup:INFO: mysql-version=5.0.38-Ubuntu_0ubuntu1.4-log
netflix:backup:INFO: backup-directory=/var/lib/mysql-zrm/netflix/20080326164433
netflix:backup:INFO: backup-level=1
netflix:backup:INFO: PHASE END: Initialization
netflix:backup:INFO: PHASE START: Running pre backup plugin
netflix:backup:INFO: PHASE END: Running pre backup plugin
netflix:backup:INFO: PHASE START: Flushing logs
netflix:backup:INFO: PHASE END: Flushing logs
netflix:backup:INFO: PHASE START: Creating incremental backup
netflix:backup:INFO: incremental=mysql-bin.[0-9]*
netflix:backup:INFO: PHASE END: Creating incremental backup
netflix:backup:INFO: PHASE START: Calculating backup size & checksums
netflix:backup:INFO: next-binlog=mysql-bin.000013
netflix:backup:INFO: last-backup=/var/lib/mysql-zrm/netflix/20080326162210
netflix:backup:INFO: backup-size=0.03 MB
netflix:backup:INFO: PHASE END: Calculating backup size & checksums
netflix:backup:INFO: PHASE START: Compression/Encryption
netflix:backup:INFO: compress=
netflix:backup:INFO: backup-size-compressed=0.00 MB
netflix:backup:INFO: PHASE END: Compression/Encryption
netflix:backup:INFO: read-locks-time=00:00:00
netflix:backup:INFO: flush-logs-time=00:00:00
netflix:backup:INFO: compress-encrypt-time=00:00:00
netflix:backup:INFO: backup-time=00:00:00
netflix:backup:INFO: backup-status=Backup succeeded
netflix:backup:INFO: Backup succeeded
netflix:backup:INFO: PHASE START: Running post backup plugin
netflix:backup:INFO: PHASE END: Running post backup plugin
netflix:backup:INFO: PHASE START: Mailing backup report
netflix:backup:INFO: PHASE END: Mailing backup report
netflix:backup:INFO: PHASE START: Cleanup
netflix:backup:INFO: PHASE END: Cleanup
netflix:backup:INFO: END OF BACKUP
/usr/bin/mysql-zrm started successfully

ZRM Backup Reports

* Use "mysql-zrm-reporter" to look at the status of backups available.

$ /usr/bin/mysql-zrm-reporter --where backup-set=netflix --show backup-status-info

REPORT TYPE : backup-status-info

backup_set backup_date backup_level backup_status comment
-----------------------------------------------------------------------------------------------------------
netflix Wed 26 Mar 2008 04:44:33 1 Backup succeeded ----
PM PDT
netflix Wed 26 Mar 2008 04:16:52 0 Backup succeeded ----
PM PDT

* ZRM reports can also provide information on impact on MySQL application.

$ /usr/bin/mysql-zrm-reporter --where backup-set=netflix --show backup-app-performance-info

REPORT TYPE : backup-app-performance-info

backup_set backup_date backup_level backup_size backup_time read_locks_time flush_logs_time
-------------------------------------------------------------------------------------------------------------------------------------
netflix Wed 26 Mar 2008 04:44:33 1 0.03 MB 00:00:00 00:00:00 00:00:00
PM PDT
netflix Wed 26 Mar 2008 04:16:52 0 122.27 MB 00:00:15 00:00:01 00:00:00
PM PDT

Database Recovery

* Use ZRM reporting tool to identify the location of MySQL backup images.

$ /usr/bin/mysql-zrm-reporter --where backup-set=netflix --show restore-info

REPORT TYPE : restore-info

backup_set backup_date backup_level backup_directory backup_status comment
-----------------------------------------------------------------------------------------------------------------------------------------------------
netflix Wed 26 Mar 2008 04:44:33 1 /var/lib/mysql-zrm/netflix/20080326164433 Backup succeeded ----
PM PDT
netflix Wed 26 Mar 2008 04:16:52 0 /var/lib/mysql-zrm/netflix/20080326161652 Backup succeeded ----
PM PDT

* You can parse incremental backups to identify database events of interest. In our example, we will look for the "DELETE" event.

$ /usr/bin/mysql-zrm-parse-binlogs --source-directory /var/lib/mysql-zrm/netflix/20080326164433 | grep delete

parse-binlogs:INFO: ZRM for MySQL Community Edition - version 2.0
/var/lib/mysql-zrm/netflix/20080326164433/mysql-bin.000011 | 13634 | 08-03-26 16:28:03 | Query | use myisamnetflix/*!*/; delete from MovieID where MovieTitle = "Alien Hunter"/*!*/;

* Restore the database from the full backup done at 16:16:52.

$ /usr/bin/mysql-zrm-restore --user=root --password=boot12 --source-directory=/var/lib/mysql-zrm/netflix/20080326161652

restore:INFO: ZRM for MySQL Community Edition - version 2.0
BackupSet1:restore:INFO: Restored database from raw backup: myisamnetflix
BackupSet1:restore:INFO: Restore done in 9 seconds.
MySQL server has been shutdown. Please restart after verification.

* Restart the MySQL server
# /etc/init.d/mysql restart
* Stopping MySQL database server mysqld [ OK ]
* Starting MySQL database server mysqld [ OK ]
* Checking for corrupt, not cleanly closed and upgrade needing tables.

* Check the database recovery.

mysql> use myisamnetflix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from MovieID where MovieTitle = "Alien Hunter";
+---------+------+--------------+
| MovieID | Year | MovieTitle |
+---------+------+--------------+
| 17770 | 2003 | Alien Hunter |
+---------+------+--------------+
1 row in set (0.02 sec)


 

Scheduled Backups With Rsyncbackup On Debian Etch - Page 2

4.3 Configuration

4.3.1 Main

This file contains the standard rsync options for all backups.

vi /etc/rsyncbackup/config.conf

The content could look like this:

--stats
--progress
--links
--hard-links
--times
--recursive
--perms
--owner
--group
--compress
--backup

Note: You can also use the short style - e.g.: "-p" instead of "--perms". I chose the long style for better understanding.

4.3.2 Sources

This file contains all files/folders that shall be available in the backup sets.

vi /etc/rsyncbackup/sources.conf

The content could look like this:

configs|local:/etc|true|
logs|local:/var/log|true|

The syntax: tag|source path|conditional shell code|optional rsync options

Note: "true" means that this source is enabled - "false" would disable it.

4.3.3 Destinations

This file contains all destinations that shall be available in the backup sets.

vi /etc/rsyncbackup/destinations.conf

The content could look like this:

store_configs|ssh[key=id_rsa,incremental=7,tag=increment]:root@192.168.0.102:/backups/configs/|/usr/bin/traceroute -m 2 192.168.0.102|--bwlimit=300 --delete
store_logs|ssh[key=id_rsa,incremental=7,tag=increment]root@192.168.0.102:/backups/logs/|/usr/bin/traceroute -m 2 192.168.0.102|--bwlimit=300 --delete
store_manual|ssh[key=id_rsa]:root@192.168.0.102:/backups/manual/|/usr/bin/traceroute -m 2 192.168.0.102|

The syntax: tag|destination path (optional with ssh & incremental settings)|conditional shell code|optional rsync options

In this example (first and second destination) we use our backup server as destination and authenticate against it with the private ssh key. We want to keep seven increments (incremental=7) whose names begin with "increment" (tag=increment). The optional shell code (/usr/bin/traceroute -m 2 192.168.0.102) will return true (and start the backup) if the backup server is running and at least two hops away. Also we use two optional rsync options (--bwlimit=300 and --delete) - so we have a bandwidth limit for this destination and deleted files on the main server will also be deleted on the backup server (for a new increment). Please note that you can only use ONE source for a backup set that has an incremental destination.

4.3.4 Backup Sets

This file joins the souces with the destinations.

vi /etc/rsyncbackup/backupset.conf

It could look like this:

[manual]
configs,logs|store_manual|true|

[daily]
logs|store_logs|true|

[weekly]
configs|store_configs|true|

As you can see, we've created three backup sets.

The syntax: source tags|destination tags|conditional shell code|optional rsync options

4.4 Test

Now let's test if our configuration is ok.

rsyncbackup -x /etc/rsyncbackup -vv -d -s manual

The output should look like this:

PATH DIR:/etc/rsyncbackup/
LOG DIR:/etc/rsyncbackup/logs
CONFIG_FILE:/etc/rsyncbackup/config.conf
SOURCE FILE:/etc/rsyncbackup/sources.conf
DESTS_FILE:/etc/rsyncbackup/destinations.conf
BACKUPSET_FILE:/etc/rsyncbackup/backupset.conf
BACKUPSET:manual

Backup set 1 configs to store_manual
Source : configs
Source dir : [local] /etc
Source opts :
Source cond : true
Destination : store_manual
Destination dir : [ssh] root@192.168.0.102:/backups/manual/ [key=id_rsa,sshport=22]
Destination opts:
Destination cond: /usr/bin/traceroute -m 2 192.168.0.102
Config options : --stats --progress --links --hard-links --times --recursive --perms --owner --group --compress --backup
Backupset opts : true
All options : --stats --progress --links --hard-links --times --recursive --perms --owner --group --compress --backup
All conditions : /usr/bin/traceroute -m 2 192.168.0.102 true true

Backup set 2 logs to store_manual
Source : logs
Source dir : [local] /var/log
Source opts :
Source cond : true
Destination : store_manual
Destination dir : [ssh] root@192.168.0.102:/backups/manual/ [key=id_rsa,sshport=22]
Destination opts:
Destination cond: /usr/bin/traceroute -m 2 192.168.0.102
Config options : --stats --progress --links --hard-links --times --recursive --perms --owner --group --compress --backup
Backupset opts : true
All options : --stats --progress --links --hard-links --times --recursive --perms --owner --group --compress --backup
All conditions : /usr/bin/traceroute -m 2 192.168.0.102 true true

If all looks ok, we'll do our first backup.

rsyncbackup -x /etc/rsyncbackup -b -s manual

After that the backup should be on the backup server - if not, have a look at the logs (/etc/rsyncbackup/logs/ or /var/log/rsyncbackup/).

4.5 Cronjob

Now we create cronjobs for the backups.

crontab -e

The content could look like this:

# m h  dom mon dow   command
# Backups
00 02 * * * /usr/local/bin/rsyncbackup -x /etc/rsyncbackup -b -v -s daily >> /var/log/rsyncbackup/backup.daily.log
00 04 * * 0 /usr/local/bin/rsyncbackup -x /etc/rsyncbackup -b -v -s weekly >> /var/log/rsyncbackup/backup.weekly.log

The backup set "daily" will be backed up every day at 2:00am, the backup set "weekly" every sunday at 4:00am. Optional, if you want to get mails when errors occurs, you can add the option "-e email@domain" to the rsyncbackup command - it should look like this:

# m h  dom mon dow   command
# Backups
00 02 * * * /usr/local/bin/rsyncbackup -x /etc/rsyncbackup -b -v -s daily -e email@domain >> /var/log/rsyncbackup/backup.daily.log
00 04 * * 0 /usr/local/bin/rsyncbackup -x /etc/rsyncbackup -b -v -s weekly -e email@domain >> /var/log/rsyncbackup/backup.weekly.log

4.6 Manual

Please have a look at the manual for further information. It is included in the package that you downloaded in step 4.1.

5 Links


 

Configure Snort to log packets to MySQL

Author : Vincent Danen, ZDNet Asia

Administrators can take advantage of the Snort facility to to detect intrusions to the network.

Snort, a network intrusion detection system, can be configured to log packets to a remote MySQL server. A graphical Web interface can be used to view captured packets and statistics.

To begin on the MySQL server, the database must first be created.

In this scenario, the Snort server is “snort.host” and the MySQL server is "mysql.host".

Connect to the database as root:

# mysql -u root -p
mysql> create database snort;
mysql> grant INSERT,SELECT,UPDATE,CREATE,DELETE,EXECUTE on snort.*
to snort@snort.host;
mysql> set password for snort@snort.host=PASSWORD('snortpass');
mysql> flush privileges;
mysql> q

With the Snort documentation comes a file called create_mysql, which has the schema for the database.

On a typical Linux install, this file would be found in /usr/share/doc/snort-[version]/create_mysql.

Load this file as root:

# mysql -u root -p snort 

Next, on the system where Snort will be running, edit the /etc/snort/snort.conf configuration file and tell it to log to the database:

output database: log, mysql, user=snort password=snortpass
dbname=snort host=mysql.host

Finally, make sure that /etc/snort/snort.conf is mode 0640 and owned root:snort:

# chown root:snort /etc/snort/snort.conf
# chmod 0640 /etc/snort/snort.conf

The next step is to start Snort; a supplied initscript will start Snort monitoring or you can launch it to the background:

# /usr/sbin/snort -c /etc/snort/snort.conf &

Starting Snort once without sending it to the background is a good idea to ensure the connection takes. You can also look on the MySQL server to ensure that logging is active:

# echo "SELECT hostname FROM sensor;" | mysql -u root -p snort

The IP address that Snort is listening on should be displayed.

Now that Snort is logging data to MySQL, using BASE (Basic Analysis and Security Engine) is a great way to view the data via a Web interface. BASE requires a Web server and PHP. Once you have unarchived it where it needs to be, copy the base_conf.php.dist file to base_conf.php and edit it, in particular, setting the $alert_dbname and related variables to point to the Snort log database.

You will also want to add a snort@localhost user with privileges to the MySQL database if you did not do so earlier (i.e., if your Snort and MySQL servers are physically separate).

Once that is done, navigate to the BASE install that you just set up and follow the instructions presented to set up the caching table for BASE. When that is complete, BASE is now available to view and graph the logged Snort data.

 

How To Install The Openbravo ERP On Debian Etch

Author: Oliver Meyer
Last edited 03/07/2008

This document describes how to set up Openbravo ERP (enterprise management system) on Debian Etch. Taken from the Openbravo page: "Openbravo is an open source ERP solution designed specifically for the SME (small to midsize firm). Developed in a web based environment, it includes many robust functionalities which are considered part of the extended ERP: procurement and warehouse management, project and service management, production management, and financial management."

I can't list all the features here - please have a look at http://www.openbravo.com/product/product-features/.

This howto is a practical guide without any warranty - it doesn't cover the theoretical backgrounds. There are many ways to set up such a system - this is the way I chose.

1 Preparation

1.1 Debian Backports

This repository provides Sun's JDK that we need for this setup.

vi /etc/apt/sources.list

Add the following lines.

# Debian Backports
deb http://www.backports.org/debian etch-backports main contrib non-free

Afterwards refresh apt ...

apt-get update

... and import the gpg-key.

apt-get install debian-backports-keyring

1.2 Needed Packages

Now let's install and configure the needed packages.

1.2.1 PostgreSQL

Install it via:

apt-get install postgresql-8.2

Afterwards we have to set the PostgreSQL admin password.

sed -i 's/ident sameuser$/trust/' /etc/postgresql/8.2/main/pg_hba.conf
/etc/init.d/postgresql-8.2 restart

Open a PostgreSQL shell.

psql -U postgres
alter role postgres with password '%new_PostgreSQL_admin_passowrd%';
\q

sed -i 's/trust$/md5/' /etc/postgresql/8.2/main/pg_hba.conf
/etc/init.d/postgresql-8.2 reload

1.2.2 Java JDK

Install it via:

apt-get install sun-java6-jdk

Afterwards make it systemwide available.

update-java-alternatives -s java-6-sun
echo 'JAVA_HOME="/usr/lib/jvm/java-6-sun"' | tee -a /etc/environment

After that log out and in again to take the changes effect.

1.2.3 Apache Tomcat

Install it via:

apt-get install tomcat5.5 tomcat5.5-admin tomcat5.5-webapps

Afterwards we have to configure it.

rm /var/log/tomcat5.5/catalina.out
vi /etc/init.d/tomcat5.5

Change:

TOMCAT5_SECURITY=yes

To:

TOMCAT5_SECURITY=no

Restart Tomcat.

/etc/init.d/tomcat5.5 restart

Now let's look if all went well.

netstat -tap | grep java

Tomcat should be listening on port 8180.

tcp6 0 0 *:8180 *:* LISTEN 3571/java

As a last resort make it systemwide available.

echo 'CATALINA_HOME="/usr/share/tomcat5.5"' | tee -a /etc/environment
echo 'CATALINA_BASE="/var/lib/tomcat5.5"' | tee -a /etc/environment
echo 'CATALINA_OPTS="-server -Xms384M -Xmx512M"' | tee -a /etc/environment

After that log out and in again to take the changes effect.

1.2.4 Apache Ant

Apache ant has already been installed as dependency at the step before - so only the configuration is left.

echo 'ANT_HOME="/usr/share/ant"' | tee -a /etc/environment

After that log out and in again to take the changes effect.

2 Openbravo

2.1 Get It

Please have a look at http://sourceforge.net/projects/openbravo/ to find out which is the latest version. When I was writing this howto it was version 2.35mp1.

cd /tmp/
wget http://mesh.dl.sourceforge.net/sourceforge/openbravo/OpenbravoERP-2.35-MP1-linux-installer.bin
chmod +x OpenbravoERP-2.35-MP1-linux-installer.bin

2.2 Installation

A text based installer will guide you through the installation.

./OpenbravoERP-2.35-MP1-linux-installer.bin

First press a few times "Enter" to read the single parts of the license agreement. Type in "yes" at the end if you agree with it.

Before the installation begins you'll be asked a few questions - answer them as follows.

  • Hit "Enter" to choose the default (/opt/OpenbravoERP) when you're asked for the installation directory.
  • Hit "Enter" to choose the default (/opt/OpenbravoERP/AppsOpenbravo/attach) when you're asked for the attachments directory.
  • Hit "Enter" to choose the default (Full (standard) installation) when you're asked for the installation type.
  • Hit "Enter" to choose the default (Full) when you're asked again for the installation type.
  • Choose PostgreSQL as database to use.
  • Hit "Enter" to choose the default (/usr/lib/jvm/java-6-sun) when you're asked for the java home directory.
  • Hit "Enter" to choose the default (/usr/share/ant) when you're asked for the Apache ant home directory.
  • Hit "Enter" to choose the default (/var/lib/tomcat5.5) when you're asked for the Tomcat installation directory.
  • Type in your web server's domain (e.g.: server1.example.com) when you're asked for it.
  • Enter "8180" when you're asked for the http port.
  • Hit "Enter" to choose the default (openbravo) when you're asked for the context name.
  • Enter "/usr/bin" when you're asked for the directory that contains the PostgreSQL binaries.
  • Hit "Enter" to choose the default (localhost) when you're asked for the database server parameters.
  • Hit "Enter" to choose the default (4532) when you're asked for PostgreSQL's listening port.
  • Hit "Enter" to choose the default (openbravo) when you're asked for the database name.
  • Next enter the PostgreSQL admin password (twice) that you created earlier at step 1.2.1.
  • Hit "Enter" to choose the default (tad) when you're asked for the openbravo database user.
  • Next type in a password (twice) for the new user.
  • Now type in "y" to start the installation - this will take a while...

2.3 Webinterface

Now you can access Openbravo via http://%servername%:8180/openbravo . Log in with the username "Openbravo" and the password "openbravo".

3 Links