You may not speak.... But the heart and mind from within say something...... It can't be hidden... it will eventually show itself from the dawn ...
Monday, June 6, 2011
Someday
Friday, May 6, 2011
Compiling the Linux Kernel – CentOS
Steps:
#yum -y install kernel-devel kernel-headers
#yum -y groupinstall “Development-Tools”
#cd /usr/src
#wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.2.tar.bz2
#tar -jxvf linux-2.6.30.2.tar.bz2
#cd /usr/src/linux-2.6.30.2/
#make menuconfig
#make clean
*#make dep (is no more necessary)
#make bzImage
#make modules
#make modules_install
#make install
*make install will copy the files: System.map, vmlinuz and the initial ram disk initrd-2.6.30.2.img to /boot. It will also add the lines you will need on grub, now just restart your computer and choose the new kernel on the grub screen.
Have Fun !!!
Friday, April 29, 2011
Setting up SendMail as SMTP Relay Server
By default relay on sendmail is disabled.
So when you do relay on it by doing telnet
220 nagios.gowireless.net ESMTP Sendmail 8.13.8/8.13.8; Fri, 29 Apr 2011 11:59:2
3 -0700
HELO
501 5.0.0 HELO requires domain address
MAIL FROM:test@test.com
250 2.1.0 test@test.com... Sender ok
relaying denied
So to allow relay on SendMail do as follows:
1. First allow the sendmail to listen to all at port 25. (Allow incoming smtp connections)
- Edit /etc/mail/sendmail.mc
Change...
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
To..
DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl
- save it
and then do
make -C /etc/mail
- restart sendmail service
service sendmail restart
2. Allow or open port 25 on the firewall.
3. Now we will include IP based authentication
- Edit /etc/mail/access and add the IP / IP block to allow relay from
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:10.1 RELAY
Connect:1.1 RELAY
- save it
- then recompile the access.db
makemap hash /etc/mail/access.db < /etc/mail/accessHopefully you find this helpful. Thanks. Take Care and God Bless!!!
- then do restart sendmail
4. To test do as follow from a different pc
telnet 10.1.10.13 25
220 nagios.gowireless.net ESMTP Sendmail 8.13.8/8.13.8; Fri, 29 Apr 2011 11:59:2
3 -0700
HELO
501 5.0.0 HELO requires domain address
MAIL FROM:test@test.com
250 2.1.0 test@test.com... Sender ok
RCPT TO:rowell.rufino@gowireless.com
250 2.1.5 rowell.rufino@gowireless.com... Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
testing
.
250 2.0.0 p3TIxNH1002876 Message accepted for delivery
quit
221 2.0.0 nagios.gowireless.net closing connection
Friday, April 8, 2011
Setting Up Mail Server on Linux
The mail server that I have setup is composed of the following components:
- a Linux OS (preferably Red Hat Enterprise or CentOS)
- Dovecot for IMAP / POP3
- Postfix for SMTP
- ClamAV for antivirus
- SpamAssassin
- MailScanner
How to install SMTP, POP3, IMAP and Webmail service
Postfix will be providing the SMTP service, Dovecot will provide the POP3 and IMAP service, while Apache and SquirrelMail will provide the Webmail service.The following are the steps we will take on setting up the mail server:
1. How to install and setup Postfix SMTP server.
2. How to install and setup Dovecot POP3 and IMAP server.
3. Configure Postfix SMTP Authentication using Dovecot SASL.
4. How to install and setup SquirrelMail WebMail.
5. How to configure the firewall.
How to install and setup Postfix SMTP server
We need to install 2 packages here namely:
- postfix and system-switch-mail
To do so, issue the following command:
# yum install postfix system-switch-mail
By default the MTA on Linux is sendmail so we need to switch from sendmail to postfix. Use the system-switch-mail tool to switch to postfix.
Configure Postfix
1. Edit the postfix configuration file.
# vi /etc/postfix/main.cf
inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain home_mailbox = Maildir/
Make sure that all mail_spool_directory lines are commented out. Otherwise, it will override the setting in the home_mailbox line above.
2. Restart postfix service
# service postfix restart
Test Postfix
1. For testing purposes, create a linux user.
# useradd johndoe
Sample postfix session. Replace johndoe with any valid user account. The dot after the line test is a command that should be typed in.
2. Perform testing.
[root@mail ~]# telnet localhost smtp Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. 220 mail.acme.local ESMTP Postfix ehlo localhost 250-mail.acme.local 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN mail from:To check if the mail indeed exists250 2.1.0 Ok rcpt to: 250 2.1.5 Ok data 354 End data with . test . 250 2.0.0 Ok: queued as 9729067C17 quit 221 2.0.0 Bye Connection closed by foreign host. [root@mail ~]#
[root@mail ~]# cd /home/johndoe/Maildir/new [root@mail new]# ls 1185669817.Vfd00I18012M795756.mail.acme.local [root@mail new]# cat 1185669817.Vfd00I18012M795756.mail.acme.localDon’t worry, you don’t have to type in the whole filename above. Just type in the first few characters say 118 then press Tab to activate automatic completion.
From johndoe@mail.acme.local Thu Feb 22 21:48:28 2007 Return-Path:If you encounter any problems, check the log file at /var/log/maillog.X-Original-To: johndoe Delivered-To: johndoe@mail.acme.local Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.acme.local (Postfix) with SMTP id 9729067C17 for ; Thu, 22 Feb 2007 21:48:26 -0500 (EST) Message-Id: <20070222134827.9729067C17@mail.acme.local> Date: Thu, 22 Feb 2007 21:48:26 -0500 (EST) From: johndoe@mail.acme.local To: undisclosed-recipients:; test [root@mail mail]#
How to install and setup Dovecot POP3 and IMAP server
1. To install dovecot:
# yum install dovecot
Configure Dovecot
1. Edit the dovecot configuration file
# vi /etc/dovecot.conf
Find the following keys and change its values as follows
protocols = pop3 pop3s imap imaps mail_location = maildir:~/Maildir/ pop3_uidl_format = %08Xu%08Xv imap_client_workarounds = delay-newmail outlook-idle netscape-eoh pop3_client_workarounds = outlook-no-nuls oe-ns-eoh2. Start Dovecot server
# service dovecot start
Test Dovecot
Sample dovecot session. Replace johndoe and password with any valid user name and password.
root@mail ~]# telnet localhost pop3 +OK dovecot ready. user johndoe +OK pass password +OK Logged in. list +OK 1 messages: 1 622 . retr 1 +OK 622 octets Return-Path:X-Original-To: johndoe Delivered-To: johndoe@mail.acme.local Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.acme.local (Postfix) with SMTP id 9729067C17 for ; Thu, 22 Feb 2007 09:06:37 -0500 (EST) Message-Id: <20070222140640.9729067C17@mail.acme.local> Date: Thu, 22 Feb 2007 09:06:37 -0500 (EST) From: johndoe@mail.acme.local To: undisclosed-recipients:; X-IMAPbase: 1172153557 1 Status: O X-UID: 1 Content-Length: 5 X-Keywords: test . quit +OK Logging out. Connection closed by foreign host. [root@mail ~]#
Configure Postfix SMTP Authentication using Dovecot SASL
SMTP Authentication (SMTP Auth) provides an access control mechanism that can be used to allow legitimate users to relay mail while denying relay service to unauthorized users, such as spammers.
Thanks to the new SASL support in Dovecot 1.0 and the new Dovecot SASL support in Postfix 2.3, setting up SMTP authentication is now easier. Instead of setting up two separate authentication for Postfix and Dovecot, we can now just setup the authentication in Dovecot and just let Postfix talk to Dovecot.
Configure Postfix and Dovecot
1. Edit the file /etc/dovecot.conf and make sure your auth default section has the lines below.
auth default { socket listen { client { path = /var/spool/postfix/private/auth mode = 0660 user = postfix group = postfix } } mechanisms = plain login }2. Edit /etc/postfix/main.cf, find the keys below and change its values as follows or add it at the bottom of the file if the key (the word before the = sign) cannot be found.
mynetworks = 127.0.0.0/8 smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination broken_sasl_auth_clients = yesThe first line says trust only localhost, meaning only localhost can send email outside the network (relay). The last line is there to support old clients like Microsoft Outlook Express 4.0 and Microsoft Exchange 5.0 just in case someone is still using it.
3. Restart the Dovecot and Postfix service. But if you installed MailScanner, restart MailScanner instead of Postfix.
Test Postfix
Sample postfix session
[root@mail ~]# telnet mail smtpReplace mail with the name of your server. We should not use localhost since localhost is a trusted client ip address. And make sure the domain name you specified does not resolve to 127.0.0.1 which is the IP address of localhost.Trying 192.168.0.1... Connected to mail.acme.local (192.168.0.1). Escape character is '^]'. 220 mail.acme.local ESMTP Postfix ehlo localhost 250-mail.acme.local 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSNNote the new 250-AUTH lines.mail from:It works, now to check if we can send it after authenticating.250 2.1.0 Ok rcpt to: 554 5.7.1 : Relay access denied
auth plain AGpvaG5kb2UAcGFzc3dvcmQ= 235 2.0.0 Authentication successful rcpt to:The gibberish text after AUTH PLAIN is the base64 encoded value of the user name johndoe and password password. You can generate your own base64 text using the form below.250 2.1.5 Ok quit 221 2.0.0 Bye Connection closed by foreign host. [root@mail ~]#
http://www.linuxmail.info/postfix-smtp-auth-dovecot-sasl/
How to install and setup SquirrelMail WebMail.
SquirrelMail is an open source standards-based webmail package written in PHP. When installed, SquirrelMail is ready out of the box. All it needs is an installed web server like Apache, SMTP server like Postfix, and IMAP server like Dovecot.
1. Get the latest stable release of Squirrelmail
# cd /usr/src
# wget http://www.squirrelmail.org/countdl.php?fileurl=http%3A%2F%2Fprdownloads.sourceforge.net%2Fsquirrelmail%2Fsquirrelmail-1.4.21.tar.gz
# tar xvzf squirrelmail-1.4.21.tar.gz
# mv squirrelmail-1.4.21 /usr/local/squirrelmail
Prepare SquirrelMail directories
Make sure to change "nogroup" to whatever group Apache will be running as. You can check what that is by looking at the value of the "Group" setting in your Apache main configuration file (probably/etc/httpd/conf/httpd.conf).# mkdir /usr/local/squirrelmail # cd /usr/local/squirrelmail # mkdir data temp # chgrp nogroup data temp # chmod 0730 data temp
Unpack SquirrelMail
# cd /usr/local/squirrelmail # tar --bzip2 -xvf /usr/local/src/downloads/squirrelmail-1.4.17.tar.bz2 # mv squirrelmail-1.4.17 www
Configure SquirrelMail
Run the SquirrelMail configuration utility.
# cd /usr/local/squirrelmail # www/configure
Select the "D" option and then configure SquirrelMail with the "uw" preset. Also make sure to set the data and attachment directory settings ("
/usr/local/squirrelmail/data" and "/usr/local/squirrelmail/temp" respectively) under "4. General Options". Make any other changes as you see fit, select "S" to save and then "Q" to quit.Configure access to SquirrelMail in Apache
Modify your main Apache configuration file (typically /etc/httpd/conf/httpd.conf) by adding the following:
"Alias /squirrelmail /usr/local/squirrelmail/wwwOptions None AllowOverride None DirectoryIndex index.php Order Allow,Deny Allow from all Deny from all Allow from all Allow from all Allow from all Allow from all Allow from all Order Deny,Allow Deny from All Allow from 127 Allow from 10 Allow from 192 Order Deny,Allow Deny from All Allow from 127 Allow from 10 Allow from 192 "
Restart apache
Reference:
http://www.linuxmail.info/squirrelmail-webmail-setup-howto-in-centos-5/
http://squirrelmail.org/docs/admin/admin-3.html#ss3.2
Thursday, January 27, 2011
How to set 100% table height
table width="100%" border="1" style="height: 100%;"
Hopefully you find this tip useful. Thank you. Take care and God Bless!!!
Tuesday, January 18, 2011
Automated Backup Script Using tar and FTP
I am posting here a script I made to automate backup via tar ang FTP. I hope that you may find this helpful. In the next post, I will try to explain each entries on the script. Thanks, take care and God Bless!!!
#!/bin/bash
# A Simple (Poor Man) disk based backup script
# Will backup all user home directories in seperate archives
# as a single /home backup file can be quite large and unwieldly.
# Does not need to be modified if users are added/deleted
# Step - 1 Create Timestamp and set up variables and functions
# BUDTSTAMP = Backup Date/Time Stamp
BUTDSTAMP=$(date +%Y%m%d)
# variable holding directories containing files to backup eg: BACKUPTHESE="/home /root /etc"
BACKUPTHESE="/var/www/html/adldap"
# Backup base place the back up base
B_BASE="/trynga"
cd $B_BASE
mkdir $B_BASE/vol
mkdir $B_BASE/vol/backup
mkdir $B_BASE/vol/backup/daily
mkdir $B_BASE/vol/backup/yesterday
mkdir $B_BASE/vol/backup/database
#directory containing today's backup
BKUPDIR="$B_BASE/vol/backup/daily"
#directory containing yesterday's backup
YDBKUPDIR="$B_BASE/vol/backup/yesterday"
#directory containing the day before yesterday's backup
DBBKUPDIR="$B_BASE/vol/backup/daybefore"
# DATABASE BACKUP DIR
DATABASEBACKUP="$B_BASE/vol/backup/database"
NCFTP="/usr/local/bin"
# device to monitor upon backup
DEVICE="/"
# recipient to send the backup report
#EMAILADD="backupadmin"
EMAILADD="rowell@mindragon.com"
# FTP SetUP
FTPS="192.168.1.118"
FTPU="rowell"
FTPP="mdi2005!"
NOW=$(date +"%d-%m-%Y")
BACKUP="$B_BASE/vol/backup/daily"
FTPD="serbackupfiles"
### MySQL Setup ###
MUSER="root"
MPASS="mdi2009!"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
# log files
LOG="/var/log/mail.txt"
ERRORLOG="/var/log/ERROR.txt"
# tag for backup file name
TAG="OpenSERbackup"
# function that quits and logs on error
exiterror()
{
# use this function by supplying $LINENO as first arg
echo "Fatal error caused by line ${1} of ${0}" >> $ERRORLOG
mail $EMAILADD -s "Backup Job ERROR" -v < $ERRORLOG
mail $EMAILADD -s "Backup Job Report" -v < $LOG
exit 1
}
# Step - 2 Start Email Message To Be Sent
# Remove mail message from previous backup
# I do this at the beginning of the script instead of the end
# in case the mail does not send for whatever reason or
# I need to debug it
rm $LOG > /dev/null 2>&1
echo "System Backup $BUTDSTAMP" >> $LOG
# The email sends a user friendly note showing the start and
# end time/dates. This is important so you can compare logs
# and see if a backup ran ok.
echo "Backup Began $(date)" >> $LOG
# Step - 3 Rotate Backups
# Simple three backupset rotation, keeps only last three
# Use directory /vol/backup as an example, make sure you change this path
# to fit your local settings. Have three directories in /vol/backup named daily,
# yesterday and daybefore.
# Make sure /vol/backup is on a different disk (preferably a different machine)
# than the files you are backing up
#looks specifically for backup files in case other files are kept in these directories
#for bkfile in $DBBKUPDIR/*; do
#echo $bkfile | grep $TAG >/dev/null &&
#(rm $bkfile || exiterror $LINENO )
#done
for bkfile in $YDBKUPDIR/*; do
echo $bkfile | grep $TAG >/dev/null &&
#(mv $bkfile $DBBKUPDIR/ || exiterror $LINENO )
(rm $bkfile || exiterror $LINENO )
done
for bkfile in $BKUPDIR/*; do
echo $bkfile | grep $TAG >/dev/null &&
(mv $bkfile $YDBKUPDIR/ || exiterror $LINENO )
done
# Step - 4 Archive Home Directories
# Creates a seperate tar file for each directory in the directories in $BACKUPTHESE
# change to dir to backup. Check in case cd failed for some reason.
cd $BACKUPTHIS || exiterror $LINENO
#backup all files listed in BACKUPTHESE
#for DIRTOBACKUP in $BACKUPTHESE; do
#for FOLDERNAME in $DIRTOBACKUP/*
#do
# Archives are created in the format someuser-$TAG-datetime.tar.gz
# basename is used here so as not to include absolute paths
# -p preserves permissions
#echo -e "-------------------\n>>>taring ${FOLDERNAME}\n\n" >> $LOG
#tar -czvpf ${BKUPDIR}/$( basename $FOLDERNAME )-${TAG}-${BUTDSTAMP}.tar.gz ${FOLDERNAME} >> $LOG || exiterror $LINENO
#done
#done
for FOLDERNAME in $BACKUPTHESE; do
echo -e "-------------------\n>>>taring ${FOLDERNAME}\n\n" >> $LOG
#tar -czvpf ${BKUPDIR}/$( basename $FOLDERNAME )-${TAG}-${BUTDSTAMP}.tar.gz ${FOLDERNAME} >> $LOG || exiterror $LINENO
tar -czvpf ${BKUPDIR}/$( basename $FOLDERNAME )-${TAG}-${BUTDSTAMP}.tar.gz ${FOLDERNAME} > /dev/null 2>&1 || exiterror $LINENO
done
# For MySQL backup database
echo -e "------------------\n>>>>back up the database\n\n" >> $LOG
### Start MySQL Backup ###
# Get all databases name
#mkdir $BACKUP/$NOW
mkdir $DATABASEBACKUP/$NOW
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
echo "$DBS \n\n " >> $LOG
for db in $DBS
do
#FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz
FILE=$DATABASEBACKUP/$NOW/mysql-$db.${BUTDSTAMP}.gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
# Step - 5 FTP backup start
echo -e "------------------\n>>>>Transfer backups to FTP server\n\n" >> $LOG
# not yet done Do an an FTP back up
# set the settings for FTP
### Dump backup using FTP ###
#Start FTP backup using ncftp
RETVAL=`$NCFTP/ncftp -u"$FTPU" -p"$FTPP" $FTPS <<EOF
mkdir $FTPD
mkdir $FTPD/$NOW
cd $FTPD/$NOW
lcd $BACKUP
mput *
lcd $DATABASEBACKUP/$NOW
mput *
quit
EOF`
echo -e "$RETVAL \n\n" >> $LOG
##### Let us use a a different version
#mkdir $FTPD
#mkdir $FTPD/$NOW
#ncftpput -m -z -u "$FTPU" -p "$FTPP" $FTPS
# Step - 6 Finish Email Report and Send
echo "Backup ended $(date)" >> $LOG
# df -h includes a human readable disk usage report of the media that /vol/backup
# is mounted on. Good to now if your backup disk is running out of space.
# Of course /dev/hdb1 is the device I use, modify it for your local settings
df -h $DEVICE >> $LOG
mail $EMAILADD -s "Backup Job Report" -v < $LOG
# Step - 7 All Done
Saturday, August 29, 2009
Installing and setting up phpPgAdmin
Requirements:
- PHP installed
- PostgreSQL installed (for instruction on how to install postgreSQL server see http://www.designmagick.com/article/2/Starting-Out/Installing-PostgreSQL)
- if you are running CentOS distro or the like then you can just do yum to install all of these needed packages.
Note: by default the installation of Postgres creates user postgres with no password (postgres by default is the superuser for PostgreSQL).
Here are the steps to take to be able to make phpPgAdmin running:
1. Download phpPgAdmin
# cd /usr/src/
# wget http://downloads.sourceforge.net/project/phppgadmin/phpPgAdmin%20%5Bstable%5D/phpPgAdmin-4.2.2/phpPgAdmin-4.2.2.tar.gz?use_mirror=nchc
2. Extract the package
# tar xvzf phpPgAdmin-4.2.2.tar.gz
3. Rename the folder and move folder to the web server document root (assuming your document root is at /var/www/html)
# mv phpPgAdmin-4.2.2 /var/www/html/phpPgAdmin
4. You should be able to browse phpPgAdmin on browser
http://xxx.xxx.xxx.xxx/phpPgAdmin/
5. Notice that what ever you put you always get "Login Failed". To correct that edit config.inc.php (located at /var/www/html/phpPgAdmin/conf/config.inc.php), set $conf['extra_login_security'] to false for now.
from
$conf['extra_login_security'] = true;
to
$conf['extra_login_security'] = false;
6. Do also the changes as follow on config.inc.php
from
$conf['servers'][0]['host'] = '';
to
$conf['servers'][0]['host'] = 'localhost'; // this is to allow tcp login
7. Now login to phpPgAdmin using username postgres without password
8. Create a user with password. (Another admin since it is advisable to use other super user account to avoid hack).
9. Once a new admin user has been created. Logout from the phpPgAdmin.
10. Edit the postgreSQL configuration (pg_hba.conf) to set md5 authentication for all connecting client via tcp. (By default all created user are trusted even without authentication). Do the changes as follow.
# vi /var/lib/pgsql/data/pg_hba.conf
from
host all all 127.0.0.1 255.255.255.255 trust
to
host all postgres 127.0.0.1 255.255.255.255 trust
host all all 127.0.0.1 255.255.255.255 md5
save the file and restart postgresql
# service postgresql restart
11. Edit again the config.inc.php and do the changes as follow:
# vi /var/www/html/conf/config.inc.php
from
$conf['extra_login_security'] = false;
to
$conf['extra_login_security'] = true;
12. Now you should be able to login using the new admin account created with password. Postgres super user will always be denied to login on phpPgAdmin for security reason.
All should be working fine from this point. You now have a running phpPgAdmin. I hope this helps for those who are establishing their PostgreSQL web admin. Cheers, Take care and God Bless!!!!